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
|
PSEUDORAMIX_DIR=pseudoramiX
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if GLAMOR
|
||||||
|
GLAMOR_DIR=glamor
|
||||||
|
endif
|
||||||
|
|
||||||
SUBDIRS = \
|
SUBDIRS = \
|
||||||
doc \
|
doc \
|
||||||
man \
|
man \
|
||||||
|
@ -55,6 +59,7 @@ SUBDIRS = \
|
||||||
$(PRESENT_DIR) \
|
$(PRESENT_DIR) \
|
||||||
$(DRI3_DIR) \
|
$(DRI3_DIR) \
|
||||||
exa \
|
exa \
|
||||||
|
$(GLAMOR_DIR) \
|
||||||
config \
|
config \
|
||||||
hw \
|
hw \
|
||||||
test
|
test
|
||||||
|
@ -106,6 +111,7 @@ DIST_SUBDIRS = \
|
||||||
composite \
|
composite \
|
||||||
glx \
|
glx \
|
||||||
exa \
|
exa \
|
||||||
|
$(GLAMOR_DIR) \
|
||||||
config \
|
config \
|
||||||
dri3 \
|
dri3 \
|
||||||
present \
|
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(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(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(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
|
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(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])
|
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([DGA], [test "x$DGA" = xyes])
|
||||||
AM_CONDITIONAL([XF86VIDMODE], [test "x$XF86VIDMODE" = xyes])
|
AM_CONDITIONAL([XF86VIDMODE], [test "x$XF86VIDMODE" = xyes])
|
||||||
AM_CONDITIONAL([XORG_BUS_PLATFORM], [test "x$CONFIG_UDEV_KMS" = 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
|
dnl XWin DDX
|
||||||
|
|
||||||
AC_MSG_CHECKING([whether to build XWin DDX])
|
AC_MSG_CHECKING([whether to build XWin DDX])
|
||||||
|
@ -2434,6 +2443,7 @@ doc/Makefile
|
||||||
doc/dtrace/Makefile
|
doc/dtrace/Makefile
|
||||||
man/Makefile
|
man/Makefile
|
||||||
fb/Makefile
|
fb/Makefile
|
||||||
|
glamor/Makefile
|
||||||
record/Makefile
|
record/Makefile
|
||||||
config/Makefile
|
config/Makefile
|
||||||
mi/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 = $(GLAMOR_LIBS)
|
||||||
libglamor_la_LIBADD = $(GLESV2_LIBS)
|
|
||||||
else
|
|
||||||
libglamor_la_LIBADD = $(GL_LIBS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
AM_CFLAGS = $(CWARNFLAGS) $(XORG_CFLAGS) $(LIBDRM_CFLAGS)
|
AM_CFLAGS = $(CWARNFLAGS) $(DIX_CFLAGS) $(GLAMOR_CFLAGS)
|
||||||
|
|
||||||
libglamor_la_LDFLAGS = -version-info 0:0:0
|
|
||||||
|
|
||||||
libglamor_la_SOURCES = \
|
libglamor_la_SOURCES = \
|
||||||
compat-api.h \
|
|
||||||
compiler.h \
|
|
||||||
glamor.c \
|
glamor.c \
|
||||||
glamor_copyarea.c \
|
glamor_copyarea.c \
|
||||||
glamor_copywindow.c \
|
glamor_copywindow.c \
|
||||||
|
@ -48,24 +40,8 @@ libglamor_la_SOURCES = \
|
||||||
glamor_compositerects.c\
|
glamor_compositerects.c\
|
||||||
glamor_xv.c\
|
glamor_xv.c\
|
||||||
glamor_utils.h\
|
glamor_utils.h\
|
||||||
glamor.h\
|
glamor.h
|
||||||
glapi.h
|
|
||||||
|
libglamor_egl_stubs_la_SOURCES = glamor_egl_stubs.c
|
||||||
|
|
||||||
sdk_HEADERS = glamor.h
|
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
|
PixmapPtr
|
||||||
glamor_get_drawable_pixmap(DrawablePtr drawable)
|
glamor_get_drawable_pixmap(DrawablePtr drawable)
|
||||||
{
|
{
|
||||||
if (drawable->type == DRAWABLE_WINDOW)
|
if (drawable->type == DRAWABLE_WINDOW)
|
||||||
return drawable->
|
return drawable->pScreen->GetWindowPixmap((WindowPtr) drawable);
|
||||||
pScreen->GetWindowPixmap((WindowPtr) drawable);
|
else
|
||||||
else
|
return (PixmapPtr) drawable;
|
||||||
return (PixmapPtr) drawable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_X_EXPORT void
|
_X_EXPORT void
|
||||||
glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type)
|
glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type)
|
||||||
{
|
{
|
||||||
glamor_pixmap_private *pixmap_priv;
|
glamor_pixmap_private *pixmap_priv;
|
||||||
glamor_screen_private *glamor_priv =
|
glamor_screen_private *glamor_priv =
|
||||||
glamor_get_screen_private(pixmap->drawable.pScreen);
|
glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||||
|
|
||||||
pixmap_priv = dixLookupPrivate(&pixmap->devPrivates,
|
pixmap_priv = dixLookupPrivate(&pixmap->devPrivates,
|
||||||
glamor_pixmap_private_key);
|
glamor_pixmap_private_key);
|
||||||
if (pixmap_priv == NULL) {
|
if (pixmap_priv == NULL) {
|
||||||
pixmap_priv = calloc(sizeof(*pixmap_priv), 1);
|
pixmap_priv = calloc(sizeof(*pixmap_priv), 1);
|
||||||
glamor_set_pixmap_private(pixmap, pixmap_priv);
|
glamor_set_pixmap_private(pixmap, pixmap_priv);
|
||||||
pixmap_priv->base.pixmap = pixmap;
|
pixmap_priv->base.pixmap = pixmap;
|
||||||
pixmap_priv->base.glamor_priv = glamor_priv;
|
pixmap_priv->base.glamor_priv = glamor_priv;
|
||||||
}
|
}
|
||||||
pixmap_priv->type = type;
|
pixmap_priv->type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
_X_EXPORT void
|
_X_EXPORT void
|
||||||
glamor_set_pixmap_texture(PixmapPtr pixmap, unsigned int tex)
|
glamor_set_pixmap_texture(PixmapPtr pixmap, unsigned int tex)
|
||||||
{
|
{
|
||||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||||
glamor_pixmap_private *pixmap_priv;
|
glamor_pixmap_private *pixmap_priv;
|
||||||
glamor_screen_private *glamor_priv;
|
glamor_screen_private *glamor_priv;
|
||||||
glamor_pixmap_fbo *fbo;
|
glamor_pixmap_fbo *fbo;
|
||||||
GLenum format;
|
GLenum format;
|
||||||
|
|
||||||
glamor_priv = glamor_get_screen_private(screen);
|
glamor_priv = glamor_get_screen_private(screen);
|
||||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||||
|
|
||||||
if (pixmap_priv->base.fbo) {
|
if (pixmap_priv->base.fbo) {
|
||||||
fbo = glamor_pixmap_detach_fbo(pixmap_priv);
|
fbo = glamor_pixmap_detach_fbo(pixmap_priv);
|
||||||
glamor_destroy_fbo(fbo);
|
glamor_destroy_fbo(fbo);
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_iformat_for_depth(pixmap->drawable.depth, &format);
|
gl_iformat_for_depth(pixmap->drawable.depth, &format);
|
||||||
fbo = glamor_create_fbo_from_tex(glamor_priv, pixmap->drawable.width,
|
fbo = glamor_create_fbo_from_tex(glamor_priv, pixmap->drawable.width,
|
||||||
pixmap->drawable.height,
|
pixmap->drawable.height, format, tex, 0);
|
||||||
format, tex, 0);
|
|
||||||
|
|
||||||
if (fbo == NULL) {
|
if (fbo == NULL) {
|
||||||
ErrorF("XXX fail to create fbo.\n");
|
ErrorF("XXX fail to create fbo.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
glamor_pixmap_attach_fbo(pixmap, fbo);
|
glamor_pixmap_attach_fbo(pixmap, fbo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_set_screen_pixmap(PixmapPtr screen_pixmap, PixmapPtr *back_pixmap)
|
glamor_set_screen_pixmap(PixmapPtr screen_pixmap, PixmapPtr *back_pixmap)
|
||||||
{
|
{
|
||||||
glamor_pixmap_private *pixmap_priv;
|
glamor_pixmap_private *pixmap_priv;
|
||||||
glamor_screen_private *glamor_priv;
|
glamor_screen_private *glamor_priv;
|
||||||
|
|
||||||
glamor_priv = glamor_get_screen_private(screen_pixmap->drawable.pScreen);
|
glamor_priv = glamor_get_screen_private(screen_pixmap->drawable.pScreen);
|
||||||
pixmap_priv = glamor_get_pixmap_private(screen_pixmap);
|
pixmap_priv = glamor_get_pixmap_private(screen_pixmap);
|
||||||
glamor_priv->screen_fbo = pixmap_priv->base.fbo->fb;
|
glamor_priv->screen_fbo = pixmap_priv->base.fbo->fb;
|
||||||
|
|
||||||
pixmap_priv->base.fbo->width = screen_pixmap->drawable.width;
|
pixmap_priv->base.fbo->width = screen_pixmap->drawable.width;
|
||||||
pixmap_priv->base.fbo->height = screen_pixmap->drawable.height;
|
pixmap_priv->base.fbo->height = screen_pixmap->drawable.height;
|
||||||
|
|
||||||
glamor_priv->back_pixmap = back_pixmap;
|
glamor_priv->back_pixmap = back_pixmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
PixmapPtr
|
PixmapPtr
|
||||||
glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
||||||
unsigned int usage)
|
unsigned int usage)
|
||||||
{
|
{
|
||||||
PixmapPtr pixmap;
|
PixmapPtr pixmap;
|
||||||
glamor_pixmap_type_t type = GLAMOR_TEXTURE_ONLY;
|
glamor_pixmap_type_t type = GLAMOR_TEXTURE_ONLY;
|
||||||
glamor_pixmap_private *pixmap_priv;
|
glamor_pixmap_private *pixmap_priv;
|
||||||
glamor_screen_private *glamor_priv =
|
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||||
glamor_get_screen_private(screen);
|
glamor_pixmap_fbo *fbo;
|
||||||
glamor_pixmap_fbo *fbo;
|
int pitch;
|
||||||
int pitch;
|
GLenum format;
|
||||||
GLenum format;
|
|
||||||
|
|
||||||
if (w > 32767 || h > 32767)
|
if (w > 32767 || h > 32767)
|
||||||
return NullPixmap;
|
return NullPixmap;
|
||||||
|
|
||||||
if ((usage == GLAMOR_CREATE_PIXMAP_CPU
|
if ((usage == GLAMOR_CREATE_PIXMAP_CPU
|
||||||
|| (usage == CREATE_PIXMAP_USAGE_GLYPH_PICTURE && w <= 64 && h <= 64)
|
|| (usage == CREATE_PIXMAP_USAGE_GLYPH_PICTURE && w <= 64 && h <= 64)
|
||||||
|| (w == 0 && h == 0)
|
|| (w == 0 && h == 0)
|
||||||
|| !glamor_check_pixmap_fbo_depth(depth))
|
|| !glamor_check_pixmap_fbo_depth(depth))
|
||||||
|| (!GLAMOR_TEXTURED_LARGE_PIXMAP &&
|
|| (!GLAMOR_TEXTURED_LARGE_PIXMAP &&
|
||||||
!glamor_check_fbo_size(glamor_priv, w, h)))
|
!glamor_check_fbo_size(glamor_priv, w, h)))
|
||||||
return fbCreatePixmap(screen, w, h, depth, usage);
|
return fbCreatePixmap(screen, w, h, depth, usage);
|
||||||
else
|
else
|
||||||
pixmap = fbCreatePixmap(screen, 0, 0, depth, usage);
|
pixmap = fbCreatePixmap(screen, 0, 0, depth, usage);
|
||||||
|
|
||||||
pixmap_priv = calloc(1, sizeof(*pixmap_priv));
|
pixmap_priv = calloc(1, sizeof(*pixmap_priv));
|
||||||
|
|
||||||
if (!pixmap_priv) {
|
if (!pixmap_priv) {
|
||||||
fbDestroyPixmap(pixmap);
|
fbDestroyPixmap(pixmap);
|
||||||
return fbCreatePixmap(screen, w, h, depth, usage);
|
return fbCreatePixmap(screen, w, h, depth, usage);
|
||||||
}
|
}
|
||||||
glamor_set_pixmap_private(pixmap, pixmap_priv);
|
glamor_set_pixmap_private(pixmap, pixmap_priv);
|
||||||
|
|
||||||
if (usage == GLAMOR_CREATE_PIXMAP_MAP)
|
if (usage == GLAMOR_CREATE_PIXMAP_MAP)
|
||||||
type = GLAMOR_MEMORY_MAP;
|
type = GLAMOR_MEMORY_MAP;
|
||||||
|
|
||||||
pixmap_priv->base.pixmap = pixmap;
|
pixmap_priv->base.pixmap = pixmap;
|
||||||
pixmap_priv->base.glamor_priv = glamor_priv;
|
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;
|
pitch = (((w * pixmap->drawable.bitsPerPixel + 7) / 8) + 3) & ~3;
|
||||||
screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, pitch, NULL);
|
screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, pitch, NULL);
|
||||||
|
|
||||||
if (type == GLAMOR_MEMORY_MAP || glamor_check_fbo_size(glamor_priv, w, h)) {
|
if (type == GLAMOR_MEMORY_MAP || glamor_check_fbo_size(glamor_priv, w, h)) {
|
||||||
pixmap_priv->type = type;
|
pixmap_priv->type = type;
|
||||||
fbo = glamor_create_fbo(glamor_priv, w, h, format, usage);
|
fbo = glamor_create_fbo(glamor_priv, w, h, format, usage);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DEBUGF("Create LARGE pixmap %p width %d height %d\n", pixmap, w, h);
|
DEBUGF("Create LARGE pixmap %p width %d height %d\n", pixmap, w, h);
|
||||||
pixmap_priv->type = GLAMOR_TEXTURE_LARGE;
|
pixmap_priv->type = GLAMOR_TEXTURE_LARGE;
|
||||||
fbo = glamor_create_fbo_array(glamor_priv, w, h, format, usage,
|
fbo = glamor_create_fbo_array(glamor_priv, w, h, format, usage,
|
||||||
glamor_priv->max_fbo_size,
|
glamor_priv->max_fbo_size,
|
||||||
glamor_priv->max_fbo_size,
|
glamor_priv->max_fbo_size, pixmap_priv);
|
||||||
pixmap_priv);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (fbo == NULL) {
|
if (fbo == NULL) {
|
||||||
fbDestroyPixmap(pixmap);
|
fbDestroyPixmap(pixmap);
|
||||||
free(pixmap_priv);
|
free(pixmap_priv);
|
||||||
return fbCreatePixmap(screen, w, h, depth, usage);
|
return fbCreatePixmap(screen, w, h, depth, usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
glamor_pixmap_attach_fbo(pixmap, fbo);
|
glamor_pixmap_attach_fbo(pixmap, fbo);
|
||||||
|
|
||||||
return pixmap;
|
return pixmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_destroy_textured_pixmap(PixmapPtr pixmap)
|
glamor_destroy_textured_pixmap(PixmapPtr pixmap)
|
||||||
{
|
{
|
||||||
if (pixmap->refcnt == 1) {
|
if (pixmap->refcnt == 1) {
|
||||||
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 != NULL)
|
if (pixmap_priv != NULL)
|
||||||
glamor_pixmap_destroy_fbo(pixmap_priv);
|
glamor_pixmap_destroy_fbo(pixmap_priv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
glamor_destroy_pixmap(PixmapPtr pixmap)
|
glamor_destroy_pixmap(PixmapPtr pixmap)
|
||||||
{
|
{
|
||||||
glamor_screen_private
|
glamor_screen_private
|
||||||
*glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
|
*glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||||
if (glamor_priv->dri3_enabled)
|
if (glamor_priv->dri3_enabled)
|
||||||
glamor_egl_destroy_textured_pixmap(pixmap);
|
glamor_egl_destroy_textured_pixmap(pixmap);
|
||||||
else
|
else
|
||||||
glamor_destroy_textured_pixmap(pixmap);
|
glamor_destroy_textured_pixmap(pixmap);
|
||||||
return fbDestroyPixmap(pixmap);
|
return fbDestroyPixmap(pixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_block_handler(ScreenPtr screen)
|
glamor_block_handler(ScreenPtr screen)
|
||||||
{
|
{
|
||||||
glamor_screen_private *glamor_priv =
|
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||||
glamor_get_screen_private(screen);
|
glamor_gl_dispatch *dispatch;
|
||||||
glamor_gl_dispatch *dispatch;
|
|
||||||
|
|
||||||
dispatch = glamor_get_dispatch(glamor_priv);
|
dispatch = glamor_get_dispatch(glamor_priv);
|
||||||
glamor_priv->tick++;
|
glamor_priv->tick++;
|
||||||
dispatch->glFlush();
|
dispatch->glFlush();
|
||||||
glamor_fbo_expire(glamor_priv);
|
glamor_fbo_expire(glamor_priv);
|
||||||
glamor_put_dispatch(glamor_priv);
|
glamor_put_dispatch(glamor_priv);
|
||||||
if (glamor_priv->state == RENDER_STATE
|
if (glamor_priv->state == RENDER_STATE
|
||||||
&& glamor_priv->render_idle_cnt++ > RENDER_IDEL_MAX) {
|
&& glamor_priv->render_idle_cnt++ > RENDER_IDEL_MAX) {
|
||||||
glamor_priv->state = IDLE_STATE;
|
glamor_priv->state = IDLE_STATE;
|
||||||
glamor_priv->render_idle_cnt = 0;
|
glamor_priv->render_idle_cnt = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_glamor_block_handler(void *data, OSTimePtr timeout,
|
_glamor_block_handler(void *data, OSTimePtr timeout, void *last_select_mask)
|
||||||
void *last_select_mask)
|
|
||||||
{
|
{
|
||||||
glamor_screen_private *glamor_priv = data;
|
glamor_screen_private *glamor_priv = data;
|
||||||
glamor_gl_dispatch *dispatch = glamor_get_dispatch(glamor_priv);
|
glamor_gl_dispatch *dispatch = glamor_get_dispatch(glamor_priv);
|
||||||
dispatch->glFlush();
|
|
||||||
glamor_put_dispatch(glamor_priv);
|
dispatch->glFlush();
|
||||||
|
glamor_put_dispatch(glamor_priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -255,374 +250,366 @@ _glamor_wakeup_handler(void *data, int result, void *last_select_mask)
|
||||||
static void
|
static void
|
||||||
glamor_set_debug_level(int *debug_level)
|
glamor_set_debug_level(int *debug_level)
|
||||||
{
|
{
|
||||||
char *debug_level_string;
|
char *debug_level_string;
|
||||||
debug_level_string = getenv("GLAMOR_DEBUG");
|
|
||||||
if (debug_level_string
|
debug_level_string = getenv("GLAMOR_DEBUG");
|
||||||
&& sscanf(debug_level_string, "%d", debug_level) == 1)
|
if (debug_level_string
|
||||||
return;
|
&& sscanf(debug_level_string, "%d", debug_level) == 1)
|
||||||
*debug_level = 0;
|
return;
|
||||||
|
*debug_level = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int glamor_debug_level;
|
int glamor_debug_level;
|
||||||
|
|
||||||
|
|
||||||
/** Set up glamor for an already-configured GL context. */
|
/** Set up glamor for an already-configured GL context. */
|
||||||
Bool
|
Bool
|
||||||
glamor_init(ScreenPtr screen, unsigned int flags)
|
glamor_init(ScreenPtr screen, unsigned int flags)
|
||||||
{
|
{
|
||||||
glamor_screen_private *glamor_priv;
|
glamor_screen_private *glamor_priv;
|
||||||
int gl_version;
|
int gl_version;
|
||||||
|
|
||||||
#ifdef RENDER
|
#ifdef RENDER
|
||||||
PictureScreenPtr ps = GetPictureScreenIfSet(screen);
|
PictureScreenPtr ps = GetPictureScreenIfSet(screen);
|
||||||
#endif
|
#endif
|
||||||
if (flags & ~GLAMOR_VALID_FLAGS) {
|
if (flags & ~GLAMOR_VALID_FLAGS) {
|
||||||
ErrorF("glamor_init: Invalid flags %x\n", flags);
|
ErrorF("glamor_init: Invalid flags %x\n", flags);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
glamor_priv = calloc(1, sizeof(*glamor_priv));
|
glamor_priv = calloc(1, sizeof(*glamor_priv));
|
||||||
if (glamor_priv == NULL)
|
if (glamor_priv == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (flags & GLAMOR_INVERTED_Y_AXIS) {
|
if (flags & GLAMOR_INVERTED_Y_AXIS) {
|
||||||
glamor_priv->yInverted = 1;
|
glamor_priv->yInverted = 1;
|
||||||
} else
|
}
|
||||||
glamor_priv->yInverted = 0;
|
else
|
||||||
|
glamor_priv->yInverted = 0;
|
||||||
|
|
||||||
if (!dixRegisterPrivateKey
|
if (!dixRegisterPrivateKey(glamor_screen_private_key, PRIVATE_SCREEN, 0)) {
|
||||||
(glamor_screen_private_key, PRIVATE_SCREEN, 0)) {
|
LogMessage(X_WARNING,
|
||||||
LogMessage(X_WARNING,
|
"glamor%d: Failed to allocate screen private\n",
|
||||||
"glamor%d: Failed to allocate screen private\n",
|
screen->myNum);
|
||||||
screen->myNum);
|
goto fail;
|
||||||
goto fail;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
glamor_set_screen_private(screen, glamor_priv);
|
glamor_set_screen_private(screen, glamor_priv);
|
||||||
|
|
||||||
if (!dixRegisterPrivateKey
|
if (!dixRegisterPrivateKey(glamor_pixmap_private_key, PRIVATE_PIXMAP, 0)) {
|
||||||
(glamor_pixmap_private_key, PRIVATE_PIXMAP, 0)) {
|
LogMessage(X_WARNING,
|
||||||
LogMessage(X_WARNING,
|
"glamor%d: Failed to allocate pixmap private\n",
|
||||||
"glamor%d: Failed to allocate pixmap private\n",
|
screen->myNum);
|
||||||
screen->myNum);
|
goto fail;;
|
||||||
goto fail;;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
gl_version = glamor_gl_get_version();
|
gl_version = glamor_gl_get_version();
|
||||||
|
|
||||||
#ifndef GLAMOR_GLES2
|
#ifndef GLAMOR_GLES2
|
||||||
if (gl_version < GLAMOR_GL_VERSION_ENCODE(1, 3)) {
|
if (gl_version < GLAMOR_GL_VERSION_ENCODE(1, 3)) {
|
||||||
ErrorF("Require OpenGL version 1.3 or latter.\n");
|
ErrorF("Require OpenGL version 1.3 or latter.\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (gl_version < GLAMOR_GL_VERSION_ENCODE(2, 0)) {
|
if (gl_version < GLAMOR_GL_VERSION_ENCODE(2, 0)) {
|
||||||
ErrorF("Require Open GLES2.0 or latter.\n");
|
ErrorF("Require Open GLES2.0 or latter.\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
glamor_gl_dispatch_init(screen, &glamor_priv->_dispatch, gl_version);
|
glamor_gl_dispatch_init(screen, &glamor_priv->_dispatch, gl_version);
|
||||||
|
|
||||||
#ifdef GLAMOR_GLES2
|
#ifdef GLAMOR_GLES2
|
||||||
if (!glamor_gl_has_extension("GL_EXT_texture_format_BGRA8888")) {
|
if (!glamor_gl_has_extension("GL_EXT_texture_format_BGRA8888")) {
|
||||||
ErrorF("GL_EXT_texture_format_BGRA8888 required\n");
|
ErrorF("GL_EXT_texture_format_BGRA8888 required\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
glamor_priv->has_pack_invert =
|
glamor_priv->has_pack_invert =
|
||||||
glamor_gl_has_extension("GL_MESA_pack_invert");
|
glamor_gl_has_extension("GL_MESA_pack_invert");
|
||||||
glamor_priv->has_fbo_blit =
|
glamor_priv->has_fbo_blit =
|
||||||
glamor_gl_has_extension("GL_EXT_framebuffer_blit");
|
glamor_gl_has_extension("GL_EXT_framebuffer_blit");
|
||||||
glamor_priv->_dispatch.glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE,
|
glamor_priv->_dispatch.glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE,
|
||||||
&glamor_priv->max_fbo_size);
|
&glamor_priv->max_fbo_size);
|
||||||
#ifdef MAX_FBO_SIZE
|
#ifdef MAX_FBO_SIZE
|
||||||
glamor_priv->max_fbo_size = MAX_FBO_SIZE;
|
glamor_priv->max_fbo_size = MAX_FBO_SIZE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
glamor_set_debug_level(&glamor_debug_level);
|
glamor_set_debug_level(&glamor_debug_level);
|
||||||
|
|
||||||
#ifdef GLAMOR_GLES2
|
#ifdef GLAMOR_GLES2
|
||||||
glamor_priv->gl_flavor = GLAMOR_GL_ES2;
|
glamor_priv->gl_flavor = GLAMOR_GL_ES2;
|
||||||
#else
|
#else
|
||||||
glamor_priv->gl_flavor = GLAMOR_GL_DESKTOP;
|
glamor_priv->gl_flavor = GLAMOR_GL_DESKTOP;
|
||||||
#endif
|
#endif
|
||||||
/* If we are using egl screen, call egl screen init to
|
/* If we are using egl screen, call egl screen init to
|
||||||
* register correct close screen function. */
|
* register correct close screen function. */
|
||||||
if (flags & GLAMOR_USE_EGL_SCREEN)
|
if (flags & GLAMOR_USE_EGL_SCREEN)
|
||||||
glamor_egl_screen_init(screen);
|
glamor_egl_screen_init(screen);
|
||||||
|
|
||||||
glamor_priv->saved_procs.close_screen = screen->CloseScreen;
|
glamor_priv->saved_procs.close_screen = screen->CloseScreen;
|
||||||
screen->CloseScreen = glamor_close_screen;
|
screen->CloseScreen = glamor_close_screen;
|
||||||
|
|
||||||
if (flags & GLAMOR_USE_SCREEN) {
|
if (flags & GLAMOR_USE_SCREEN) {
|
||||||
if (!RegisterBlockAndWakeupHandlers(_glamor_block_handler,
|
if (!RegisterBlockAndWakeupHandlers(_glamor_block_handler,
|
||||||
_glamor_wakeup_handler,
|
_glamor_wakeup_handler,
|
||||||
glamor_priv)) {
|
glamor_priv)) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
glamor_priv->saved_procs.create_gc = screen->CreateGC;
|
glamor_priv->saved_procs.create_gc = screen->CreateGC;
|
||||||
screen->CreateGC = glamor_create_gc;
|
screen->CreateGC = glamor_create_gc;
|
||||||
|
|
||||||
glamor_priv->saved_procs.create_pixmap = screen->CreatePixmap;
|
glamor_priv->saved_procs.create_pixmap = screen->CreatePixmap;
|
||||||
screen->CreatePixmap = glamor_create_pixmap;
|
screen->CreatePixmap = glamor_create_pixmap;
|
||||||
|
|
||||||
glamor_priv->saved_procs.destroy_pixmap = screen->DestroyPixmap;
|
glamor_priv->saved_procs.destroy_pixmap = screen->DestroyPixmap;
|
||||||
screen->DestroyPixmap = glamor_destroy_pixmap;
|
screen->DestroyPixmap = glamor_destroy_pixmap;
|
||||||
|
|
||||||
glamor_priv->saved_procs.get_spans = screen->GetSpans;
|
glamor_priv->saved_procs.get_spans = screen->GetSpans;
|
||||||
screen->GetSpans = glamor_get_spans;
|
screen->GetSpans = glamor_get_spans;
|
||||||
|
|
||||||
glamor_priv->saved_procs.get_image = screen->GetImage;
|
glamor_priv->saved_procs.get_image = screen->GetImage;
|
||||||
screen->GetImage = glamor_get_image;
|
screen->GetImage = glamor_get_image;
|
||||||
|
|
||||||
glamor_priv->saved_procs.change_window_attributes =
|
glamor_priv->saved_procs.change_window_attributes =
|
||||||
screen->ChangeWindowAttributes;
|
screen->ChangeWindowAttributes;
|
||||||
screen->ChangeWindowAttributes =
|
screen->ChangeWindowAttributes = glamor_change_window_attributes;
|
||||||
glamor_change_window_attributes;
|
|
||||||
|
|
||||||
glamor_priv->saved_procs.copy_window = screen->CopyWindow;
|
glamor_priv->saved_procs.copy_window = screen->CopyWindow;
|
||||||
screen->CopyWindow = glamor_copy_window;
|
screen->CopyWindow = glamor_copy_window;
|
||||||
|
|
||||||
glamor_priv->saved_procs.bitmap_to_region =
|
glamor_priv->saved_procs.bitmap_to_region = screen->BitmapToRegion;
|
||||||
screen->BitmapToRegion;
|
screen->BitmapToRegion = glamor_bitmap_to_region;
|
||||||
screen->BitmapToRegion = glamor_bitmap_to_region;
|
}
|
||||||
}
|
|
||||||
#ifdef RENDER
|
#ifdef RENDER
|
||||||
if (flags & GLAMOR_USE_PICTURE_SCREEN) {
|
if (flags & GLAMOR_USE_PICTURE_SCREEN) {
|
||||||
glamor_priv->saved_procs.composite = ps->Composite;
|
glamor_priv->saved_procs.composite = ps->Composite;
|
||||||
ps->Composite = glamor_composite;
|
ps->Composite = glamor_composite;
|
||||||
|
|
||||||
|
glamor_priv->saved_procs.trapezoids = ps->Trapezoids;
|
||||||
|
ps->Trapezoids = glamor_trapezoids;
|
||||||
|
|
||||||
glamor_priv->saved_procs.trapezoids = ps->Trapezoids;
|
glamor_priv->saved_procs.triangles = ps->Triangles;
|
||||||
ps->Trapezoids = glamor_trapezoids;
|
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;
|
glamor_priv->saved_procs.composite_rects = ps->CompositeRects;
|
||||||
ps->AddTraps = glamor_add_traps;
|
ps->CompositeRects = glamor_composite_rectangles;
|
||||||
|
|
||||||
}
|
glamor_priv->saved_procs.glyphs = ps->Glyphs;
|
||||||
|
ps->Glyphs = glamor_glyphs;
|
||||||
|
|
||||||
glamor_priv->saved_procs.composite_rects = ps->CompositeRects;
|
glamor_priv->saved_procs.unrealize_glyph = ps->UnrealizeGlyph;
|
||||||
ps->CompositeRects = glamor_composite_rectangles;
|
ps->UnrealizeGlyph = glamor_glyph_unrealize;
|
||||||
|
|
||||||
glamor_priv->saved_procs.glyphs = ps->Glyphs;
|
glamor_priv->saved_procs.create_picture = ps->CreatePicture;
|
||||||
ps->Glyphs = glamor_glyphs;
|
ps->CreatePicture = glamor_create_picture;
|
||||||
|
|
||||||
glamor_priv->saved_procs.unrealize_glyph = ps->UnrealizeGlyph;
|
glamor_priv->saved_procs.set_window_pixmap = screen->SetWindowPixmap;
|
||||||
ps->UnrealizeGlyph = glamor_glyph_unrealize;
|
screen->SetWindowPixmap = glamor_set_window_pixmap;
|
||||||
|
|
||||||
glamor_priv->saved_procs.create_picture = ps->CreatePicture;
|
glamor_priv->saved_procs.destroy_picture = ps->DestroyPicture;
|
||||||
ps->CreatePicture = glamor_create_picture;
|
ps->DestroyPicture = glamor_destroy_picture;
|
||||||
|
glamor_init_composite_shaders(screen);
|
||||||
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);
|
|
||||||
#endif
|
#endif
|
||||||
glamor_init_pixmap_fbo(screen);
|
glamor_init_pixmap_fbo(screen);
|
||||||
glamor_init_solid_shader(screen);
|
glamor_init_solid_shader(screen);
|
||||||
glamor_init_tile_shader(screen);
|
glamor_init_tile_shader(screen);
|
||||||
#ifdef GLAMOR_TRAPEZOID_SHADER
|
#ifdef GLAMOR_TRAPEZOID_SHADER
|
||||||
glamor_init_trapezoid_shader(screen);
|
glamor_init_trapezoid_shader(screen);
|
||||||
#endif
|
#endif
|
||||||
glamor_init_putimage_shaders(screen);
|
glamor_init_putimage_shaders(screen);
|
||||||
glamor_init_finish_access_shaders(screen);
|
glamor_init_finish_access_shaders(screen);
|
||||||
#ifdef GLAMOR_GRADIENT_SHADER
|
#ifdef GLAMOR_GRADIENT_SHADER
|
||||||
glamor_init_gradient_shader(screen);
|
glamor_init_gradient_shader(screen);
|
||||||
#endif
|
#endif
|
||||||
#ifdef GLAMOR_XV
|
#ifdef GLAMOR_XV
|
||||||
glamor_init_xv_shader(screen);
|
glamor_init_xv_shader(screen);
|
||||||
#endif
|
#endif
|
||||||
glamor_pixmap_init(screen);
|
glamor_pixmap_init(screen);
|
||||||
|
|
||||||
glamor_priv->flags = flags;
|
glamor_priv->flags = flags;
|
||||||
glamor_priv->screen = screen;
|
glamor_priv->screen = screen;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
free(glamor_priv);
|
free(glamor_priv);
|
||||||
glamor_set_screen_private(screen, NULL);
|
glamor_set_screen_private(screen, NULL);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
glamor_release_screen_priv(ScreenPtr screen)
|
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
|
#ifdef GLAMOR_XV
|
||||||
glamor_fini_xv_shader(screen);
|
glamor_fini_xv_shader(screen);
|
||||||
#endif
|
#endif
|
||||||
#ifdef RENDER
|
#ifdef RENDER
|
||||||
glamor_fini_composite_shaders(screen);
|
glamor_fini_composite_shaders(screen);
|
||||||
#endif
|
#endif
|
||||||
glamor_fini_pixmap_fbo(screen);
|
glamor_fini_pixmap_fbo(screen);
|
||||||
glamor_fini_solid_shader(screen);
|
glamor_fini_solid_shader(screen);
|
||||||
glamor_fini_tile_shader(screen);
|
glamor_fini_tile_shader(screen);
|
||||||
#ifdef GLAMOR_TRAPEZOID_SHADER
|
#ifdef GLAMOR_TRAPEZOID_SHADER
|
||||||
glamor_fini_trapezoid_shader(screen);
|
glamor_fini_trapezoid_shader(screen);
|
||||||
#endif
|
#endif
|
||||||
glamor_fini_putimage_shaders(screen);
|
glamor_fini_putimage_shaders(screen);
|
||||||
glamor_fini_finish_access_shaders(screen);
|
glamor_fini_finish_access_shaders(screen);
|
||||||
#ifdef GLAMOR_GRADIENT_SHADER
|
#ifdef GLAMOR_GRADIENT_SHADER
|
||||||
glamor_fini_gradient_shader(screen);
|
glamor_fini_gradient_shader(screen);
|
||||||
#endif
|
#endif
|
||||||
glamor_pixmap_fini(screen);
|
glamor_pixmap_fini(screen);
|
||||||
free(glamor_priv);
|
free(glamor_priv);
|
||||||
|
|
||||||
glamor_set_screen_private(screen, NULL);
|
glamor_set_screen_private(screen, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
_X_EXPORT void
|
_X_EXPORT void
|
||||||
glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv)
|
glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv)
|
||||||
{
|
{
|
||||||
glamor_pixmap_private *old_priv;
|
glamor_pixmap_private *old_priv;
|
||||||
glamor_pixmap_fbo *fbo;
|
glamor_pixmap_fbo *fbo;
|
||||||
|
|
||||||
old_priv = dixGetPrivate(&pixmap->devPrivates, glamor_pixmap_private_key);
|
old_priv = dixGetPrivate(&pixmap->devPrivates, glamor_pixmap_private_key);
|
||||||
|
|
||||||
if (priv) {
|
if (priv) {
|
||||||
assert(old_priv == NULL);
|
assert(old_priv == NULL);
|
||||||
} else {
|
}
|
||||||
if (old_priv == NULL)
|
else {
|
||||||
return;
|
if (old_priv == NULL)
|
||||||
fbo = glamor_pixmap_detach_fbo(old_priv);
|
return;
|
||||||
glamor_purge_fbo(fbo);
|
fbo = glamor_pixmap_detach_fbo(old_priv);
|
||||||
free(old_priv);
|
glamor_purge_fbo(fbo);
|
||||||
}
|
free(old_priv);
|
||||||
|
}
|
||||||
|
|
||||||
dixSetPrivate(&pixmap->devPrivates,
|
dixSetPrivate(&pixmap->devPrivates, glamor_pixmap_private_key, priv);
|
||||||
glamor_pixmap_private_key,
|
|
||||||
priv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
glamor_close_screen(CLOSE_SCREEN_ARGS_DECL)
|
glamor_close_screen(ScreenPtr screen)
|
||||||
{
|
{
|
||||||
glamor_screen_private *glamor_priv;
|
glamor_screen_private *glamor_priv;
|
||||||
PixmapPtr screen_pixmap;
|
PixmapPtr screen_pixmap;
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
#ifdef RENDER
|
#ifdef RENDER
|
||||||
PictureScreenPtr ps = GetPictureScreenIfSet(screen);
|
PictureScreenPtr ps = GetPictureScreenIfSet(screen);
|
||||||
#endif
|
#endif
|
||||||
glamor_priv = glamor_get_screen_private(screen);
|
glamor_priv = glamor_get_screen_private(screen);
|
||||||
flags = glamor_priv->flags;
|
flags = glamor_priv->flags;
|
||||||
glamor_glyphs_fini(screen);
|
glamor_glyphs_fini(screen);
|
||||||
screen->CloseScreen = glamor_priv->saved_procs.close_screen;
|
screen->CloseScreen = glamor_priv->saved_procs.close_screen;
|
||||||
if (flags & GLAMOR_USE_SCREEN) {
|
if (flags & GLAMOR_USE_SCREEN) {
|
||||||
|
|
||||||
screen->CreateGC = glamor_priv->saved_procs.create_gc;
|
screen->CreateGC = glamor_priv->saved_procs.create_gc;
|
||||||
screen->CreatePixmap = glamor_priv->saved_procs.create_pixmap;
|
screen->CreatePixmap = glamor_priv->saved_procs.create_pixmap;
|
||||||
screen->DestroyPixmap = glamor_priv->saved_procs.destroy_pixmap;
|
screen->DestroyPixmap = glamor_priv->saved_procs.destroy_pixmap;
|
||||||
screen->GetSpans = glamor_priv->saved_procs.get_spans;
|
screen->GetSpans = glamor_priv->saved_procs.get_spans;
|
||||||
screen->ChangeWindowAttributes =
|
screen->ChangeWindowAttributes =
|
||||||
glamor_priv->saved_procs.change_window_attributes;
|
glamor_priv->saved_procs.change_window_attributes;
|
||||||
screen->CopyWindow = glamor_priv->saved_procs.copy_window;
|
screen->CopyWindow = glamor_priv->saved_procs.copy_window;
|
||||||
screen->BitmapToRegion = glamor_priv->saved_procs.bitmap_to_region;
|
screen->BitmapToRegion = glamor_priv->saved_procs.bitmap_to_region;
|
||||||
}
|
}
|
||||||
#ifdef RENDER
|
#ifdef RENDER
|
||||||
if (ps && (flags & GLAMOR_USE_PICTURE_SCREEN)) {
|
if (ps && (flags & GLAMOR_USE_PICTURE_SCREEN)) {
|
||||||
|
|
||||||
ps->Composite = glamor_priv->saved_procs.composite;
|
ps->Composite = glamor_priv->saved_procs.composite;
|
||||||
ps->Trapezoids = glamor_priv->saved_procs.trapezoids;
|
ps->Trapezoids = glamor_priv->saved_procs.trapezoids;
|
||||||
ps->Triangles = glamor_priv->saved_procs.triangles;
|
ps->Triangles = glamor_priv->saved_procs.triangles;
|
||||||
ps->CreatePicture = glamor_priv->saved_procs.create_picture;
|
ps->CreatePicture = glamor_priv->saved_procs.create_picture;
|
||||||
}
|
}
|
||||||
ps->CompositeRects = glamor_priv->saved_procs.composite_rects;
|
ps->CompositeRects = glamor_priv->saved_procs.composite_rects;
|
||||||
ps->Glyphs = glamor_priv->saved_procs.glyphs;
|
ps->Glyphs = glamor_priv->saved_procs.glyphs;
|
||||||
ps->UnrealizeGlyph = glamor_priv->saved_procs.unrealize_glyph;
|
ps->UnrealizeGlyph = glamor_priv->saved_procs.unrealize_glyph;
|
||||||
screen->SetWindowPixmap = glamor_priv->saved_procs.set_window_pixmap;
|
screen->SetWindowPixmap = glamor_priv->saved_procs.set_window_pixmap;
|
||||||
#endif
|
#endif
|
||||||
screen_pixmap = screen->GetScreenPixmap(screen);
|
screen_pixmap = screen->GetScreenPixmap(screen);
|
||||||
glamor_set_pixmap_private(screen_pixmap, NULL);
|
glamor_set_pixmap_private(screen_pixmap, NULL);
|
||||||
if (glamor_priv->back_pixmap && *glamor_priv->back_pixmap)
|
if (glamor_priv->back_pixmap && *glamor_priv->back_pixmap)
|
||||||
glamor_set_pixmap_private(*glamor_priv->back_pixmap, NULL);
|
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
|
void
|
||||||
glamor_fini(ScreenPtr screen)
|
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_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||||
glamor_get_screen_private(screen);
|
|
||||||
glamor_priv->dri3_enabled = TRUE;
|
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_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||||
glamor_get_screen_private(screen);
|
|
||||||
return glamor_priv->dri3_enabled;
|
return glamor_priv->dri3_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
glamor_dri3_fd_from_pixmap (ScreenPtr screen,
|
glamor_dri3_fd_from_pixmap(ScreenPtr screen,
|
||||||
PixmapPtr pixmap,
|
PixmapPtr pixmap, CARD16 *stride, CARD32 *size)
|
||||||
CARD16 *stride,
|
|
||||||
CARD32 *size)
|
|
||||||
{
|
{
|
||||||
glamor_pixmap_private *pixmap_priv;
|
glamor_pixmap_private *pixmap_priv;
|
||||||
glamor_screen_private *glamor_priv =
|
glamor_screen_private *glamor_priv =
|
||||||
glamor_get_screen_private(pixmap->drawable.pScreen);
|
glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||||
|
|
||||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||||
if (pixmap_priv == NULL || !glamor_priv->dri3_enabled)
|
if (pixmap_priv == NULL || !glamor_priv->dri3_enabled)
|
||||||
return -1;
|
return -1;
|
||||||
switch (pixmap_priv->type)
|
switch (pixmap_priv->type) {
|
||||||
{
|
case GLAMOR_TEXTURE_DRM:
|
||||||
case GLAMOR_TEXTURE_DRM:
|
case GLAMOR_TEXTURE_ONLY:
|
||||||
case GLAMOR_TEXTURE_ONLY:
|
glamor_pixmap_ensure_fbo(pixmap, GL_RGBA, 0);
|
||||||
glamor_pixmap_ensure_fbo(pixmap, GL_RGBA, 0);
|
return glamor_egl_dri3_fd_name_from_tex(screen,
|
||||||
return glamor_egl_dri3_fd_name_from_tex(screen,
|
pixmap,
|
||||||
pixmap,
|
pixmap_priv->base.fbo->tex,
|
||||||
pixmap_priv->base.fbo->tex,
|
FALSE, stride, size);
|
||||||
FALSE,
|
default:
|
||||||
stride,
|
break;
|
||||||
size);
|
}
|
||||||
default: break;
|
return -1;
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
glamor_dri3_name_from_pixmap (PixmapPtr pixmap)
|
glamor_dri3_name_from_pixmap(PixmapPtr pixmap)
|
||||||
{
|
{
|
||||||
glamor_pixmap_private *pixmap_priv;
|
glamor_pixmap_private *pixmap_priv;
|
||||||
glamor_screen_private *glamor_priv =
|
glamor_screen_private *glamor_priv =
|
||||||
glamor_get_screen_private(pixmap->drawable.pScreen);
|
glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||||
|
|
||||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||||
if (pixmap_priv == NULL || !glamor_priv->dri3_enabled)
|
if (pixmap_priv == NULL || !glamor_priv->dri3_enabled)
|
||||||
return -1;
|
return -1;
|
||||||
switch (pixmap_priv->type)
|
switch (pixmap_priv->type) {
|
||||||
{
|
case GLAMOR_TEXTURE_DRM:
|
||||||
case GLAMOR_TEXTURE_DRM:
|
case GLAMOR_TEXTURE_ONLY:
|
||||||
case GLAMOR_TEXTURE_ONLY:
|
glamor_pixmap_ensure_fbo(pixmap, GL_RGBA, 0);
|
||||||
glamor_pixmap_ensure_fbo(pixmap, GL_RGBA, 0);
|
return glamor_egl_dri3_fd_name_from_tex(pixmap->drawable.pScreen,
|
||||||
return glamor_egl_dri3_fd_name_from_tex(pixmap->drawable.pScreen,
|
pixmap,
|
||||||
pixmap,
|
pixmap_priv->base.fbo->tex,
|
||||||
pixmap_priv->base.fbo->tex,
|
TRUE, NULL, NULL);
|
||||||
TRUE,
|
default:
|
||||||
NULL,
|
break;
|
||||||
NULL);
|
}
|
||||||
default: break;
|
return -1;
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
255
glamor/glamor.h
255
glamor/glamor.h
|
@ -30,14 +30,12 @@
|
||||||
#define GLAMOR_H
|
#define GLAMOR_H
|
||||||
|
|
||||||
#include <scrnintstr.h>
|
#include <scrnintstr.h>
|
||||||
#include <xf86.h>
|
|
||||||
#include <xf86str.h>
|
|
||||||
#include <pixmapstr.h>
|
#include <pixmapstr.h>
|
||||||
#include <gcstruct.h>
|
#include <gcstruct.h>
|
||||||
#include <picturestr.h>
|
#include <picturestr.h>
|
||||||
#include <fb.h>
|
#include <fb.h>
|
||||||
#include <fbpict.h>
|
#include <fbpict.h>
|
||||||
#include <xf86xv.h>
|
|
||||||
/*
|
/*
|
||||||
* glamor_pixmap_type : glamor pixmap's type.
|
* glamor_pixmap_type : glamor pixmap's type.
|
||||||
* @MEMORY: pixmap is in memory.
|
* @MEMORY: pixmap is in memory.
|
||||||
|
@ -48,15 +46,15 @@
|
||||||
* @DRM_ONLY: pixmap is in a external DRM buffer.
|
* @DRM_ONLY: pixmap is in a external DRM buffer.
|
||||||
* @TEXTURE_ONLY: pixmap is in an internal texture.
|
* @TEXTURE_ONLY: pixmap is in an internal texture.
|
||||||
*/
|
*/
|
||||||
typedef enum glamor_pixmap_type {
|
typedef enum glamor_pixmap_type {
|
||||||
GLAMOR_MEMORY,
|
GLAMOR_MEMORY,
|
||||||
GLAMOR_MEMORY_MAP,
|
GLAMOR_MEMORY_MAP,
|
||||||
GLAMOR_TEXTURE_DRM,
|
GLAMOR_TEXTURE_DRM,
|
||||||
GLAMOR_SEPARATE_TEXTURE,
|
GLAMOR_SEPARATE_TEXTURE,
|
||||||
GLAMOR_DRM_ONLY,
|
GLAMOR_DRM_ONLY,
|
||||||
GLAMOR_TEXTURE_ONLY,
|
GLAMOR_TEXTURE_ONLY,
|
||||||
GLAMOR_TEXTURE_LARGE,
|
GLAMOR_TEXTURE_LARGE,
|
||||||
GLAMOR_TEXTURE_PACK
|
GLAMOR_TEXTURE_PACK
|
||||||
} glamor_pixmap_type_t;
|
} glamor_pixmap_type_t;
|
||||||
|
|
||||||
#define GLAMOR_EGL_EXTERNAL_BUFFER 3
|
#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
|
* screen pixmap which must be a glamor pixmap and requires
|
||||||
* the internal data structure still exist at that time.
|
* the internal data structure still exist at that time.
|
||||||
* Otherwise, the glamor internal structure will not be freed.*/
|
* 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);
|
extern _X_EXPORT Bool glamor_close_screen(ScreenPtr screen);
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* Let glamor to know the screen's fbo. The low level
|
/* Let glamor to know the screen's fbo. The low level
|
||||||
* driver should already assign a tex
|
* driver should already assign a tex
|
||||||
* to this pixmap through the set_pixmap_texture. */
|
* 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.
|
/* @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 Bool glamor_glyphs_init(ScreenPtr pScreen);
|
||||||
|
|
||||||
extern _X_EXPORT void glamor_set_pixmap_texture(PixmapPtr pixmap,
|
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_destroy_textured_pixmap(PixmapPtr pixmap);
|
||||||
extern _X_EXPORT void glamor_block_handler(ScreenPtr screen);
|
extern _X_EXPORT void glamor_block_handler(ScreenPtr screen);
|
||||||
extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h,
|
||||||
unsigned int usage);
|
int depth, unsigned int usage);
|
||||||
|
|
||||||
extern _X_EXPORT void glamor_egl_screen_init(ScreenPtr screen);
|
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
|
* Used by the DRI2 page flip. This function will exchange the KHR images and
|
||||||
* fbos of the two pixmaps.
|
* 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 */
|
/* The DDX is not supposed to call these three functions */
|
||||||
extern _X_EXPORT void glamor_enable_dri3(ScreenPtr screen);
|
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 unsigned int glamor_egl_create_argb8888_based_texture(ScreenPtr
|
||||||
extern _X_EXPORT int glamor_egl_dri3_fd_name_from_tex(ScreenPtr, PixmapPtr, unsigned int, Bool, CARD16*, CARD32*);
|
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.
|
/* @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.
|
* content.
|
||||||
* Returns the fd on success, -1 on error.
|
* Returns the fd on success, -1 on error.
|
||||||
* */
|
* */
|
||||||
extern _X_EXPORT int glamor_dri3_fd_from_pixmap (ScreenPtr screen,
|
extern _X_EXPORT int glamor_dri3_fd_from_pixmap(ScreenPtr screen,
|
||||||
PixmapPtr pixmap,
|
PixmapPtr pixmap,
|
||||||
CARD16 *stride,
|
CARD16 *stride, CARD32 *size);
|
||||||
CARD32 *size);
|
|
||||||
|
|
||||||
/* @glamor_dri3_name_from_pixmap: helper to get an gem name from a pixmap.
|
/* @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.
|
* glamor DRI3 support to be activated.
|
||||||
* Returns the name on success, -1 on error.
|
* 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.
|
/* @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.
|
* Returns a valid pixmap if the import succeeded, else NULL.
|
||||||
* */
|
* */
|
||||||
extern _X_EXPORT PixmapPtr glamor_egl_dri3_pixmap_from_fd (ScreenPtr screen,
|
extern _X_EXPORT PixmapPtr glamor_egl_dri3_pixmap_from_fd(ScreenPtr screen,
|
||||||
int fd,
|
int fd,
|
||||||
CARD16 width,
|
CARD16 width,
|
||||||
CARD16 height,
|
CARD16 height,
|
||||||
CARD16 stride,
|
CARD16 stride,
|
||||||
CARD8 depth,
|
CARD8 depth,
|
||||||
CARD8 bpp);
|
CARD8 bpp);
|
||||||
|
|
||||||
#ifdef GLAMOR_FOR_XORG
|
#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.
|
* screen pixmap is a special, we handle it separately in this function.
|
||||||
*/
|
*/
|
||||||
extern _X_EXPORT Bool glamor_egl_create_textured_screen(ScreenPtr screen,
|
extern _X_EXPORT Bool glamor_egl_create_textured_screen(ScreenPtr screen,
|
||||||
int handle,
|
int handle, int stride);
|
||||||
int stride);
|
|
||||||
|
|
||||||
/* @glamor_egl_create_textured_screen_ext:
|
/* @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.
|
* 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,
|
extern _X_EXPORT Bool glamor_egl_create_textured_screen_ext(ScreenPtr screen,
|
||||||
int handle,
|
int handle,
|
||||||
int stride,
|
int stride,
|
||||||
PixmapPtr *back_pixmap);
|
PixmapPtr
|
||||||
|
*back_pixmap);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @glamor_egl_create_textured_pixmap: Try to create a textured pixmap from
|
* @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.
|
* as well. Return true if successful, otherwise return FALSE.
|
||||||
*/
|
*/
|
||||||
extern _X_EXPORT Bool glamor_egl_create_textured_pixmap(PixmapPtr pixmap,
|
extern _X_EXPORT Bool glamor_egl_create_textured_pixmap(PixmapPtr pixmap,
|
||||||
int handle,
|
int handle, int stride);
|
||||||
int stride);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @glamor_egl_create_textured_pixmap_from_bo: Try to create a textured pixmap
|
* @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.
|
* This function is similar to glamor_egl_create_textured_pixmap.
|
||||||
*/
|
*/
|
||||||
extern _X_EXPORT Bool
|
extern _X_EXPORT Bool
|
||||||
glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap,
|
glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo);
|
||||||
void *bo);
|
|
||||||
|
|
||||||
#endif
|
#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 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.
|
/* Glamor rendering/drawing functions with XXX_nf.
|
||||||
* nf means no fallback within glamor internal if possible. If glamor
|
* nf means no fallback within glamor internal if possible. If glamor
|
||||||
* fail to accelerate the operation, glamor will return a false, and the
|
* fail to accelerate the operation, glamor will return a false, and the
|
||||||
* caller need to implement fallback method. Return a true means the
|
* caller need to implement fallback method. Return a true means the
|
||||||
* rendering request get done successfully. */
|
* rendering request get done successfully. */
|
||||||
extern _X_EXPORT Bool glamor_fill_spans_nf(DrawablePtr drawable,
|
extern _X_EXPORT Bool glamor_fill_spans_nf(DrawablePtr drawable,
|
||||||
GCPtr gc,
|
GCPtr gc,
|
||||||
int n, DDXPointPtr points,
|
int n, DDXPointPtr points,
|
||||||
int *widths, int sorted);
|
int *widths, int sorted);
|
||||||
|
|
||||||
extern _X_EXPORT Bool glamor_poly_fill_rect_nf(DrawablePtr drawable,
|
extern _X_EXPORT Bool glamor_poly_fill_rect_nf(DrawablePtr drawable,
|
||||||
GCPtr gc,
|
GCPtr gc,
|
||||||
int nrect,
|
int nrect, xRectangle *prect);
|
||||||
xRectangle * prect);
|
|
||||||
|
|
||||||
extern _X_EXPORT Bool glamor_put_image_nf(DrawablePtr drawable,
|
extern _X_EXPORT Bool glamor_put_image_nf(DrawablePtr drawable,
|
||||||
GCPtr gc, int depth, int x, int y,
|
GCPtr gc, int depth, int x, int y,
|
||||||
int w, int h, int left_pad,
|
int w, int h, int left_pad,
|
||||||
int image_format, char *bits);
|
int image_format, char *bits);
|
||||||
|
|
||||||
extern _X_EXPORT Bool glamor_copy_n_to_n_nf(DrawablePtr src,
|
extern _X_EXPORT Bool glamor_copy_n_to_n_nf(DrawablePtr src,
|
||||||
DrawablePtr dst,
|
DrawablePtr dst,
|
||||||
GCPtr gc,
|
GCPtr gc,
|
||||||
BoxPtr box,
|
BoxPtr box,
|
||||||
int nbox,
|
int nbox,
|
||||||
int dx,
|
int dx,
|
||||||
int dy,
|
int dy,
|
||||||
Bool reverse,
|
Bool reverse,
|
||||||
Bool upsidedown, Pixel bitplane,
|
Bool upsidedown, Pixel bitplane,
|
||||||
void *closure);
|
void *closure);
|
||||||
|
|
||||||
extern _X_EXPORT Bool glamor_composite_nf(CARD8 op,
|
extern _X_EXPORT Bool glamor_composite_nf(CARD8 op,
|
||||||
PicturePtr source,
|
PicturePtr source,
|
||||||
PicturePtr mask,
|
PicturePtr mask,
|
||||||
PicturePtr dest,
|
PicturePtr dest,
|
||||||
INT16 x_source,
|
INT16 x_source,
|
||||||
INT16 y_source,
|
INT16 y_source,
|
||||||
INT16 x_mask,
|
INT16 x_mask,
|
||||||
INT16 y_mask,
|
INT16 y_mask,
|
||||||
INT16 x_dest, INT16 y_dest,
|
INT16 x_dest, INT16 y_dest,
|
||||||
CARD16 width, CARD16 height);
|
CARD16 width, CARD16 height);
|
||||||
|
|
||||||
extern _X_EXPORT Bool glamor_trapezoids_nf(CARD8 op,
|
extern _X_EXPORT Bool glamor_trapezoids_nf(CARD8 op,
|
||||||
PicturePtr src, PicturePtr dst,
|
PicturePtr src, PicturePtr dst,
|
||||||
PictFormatPtr mask_format,
|
PictFormatPtr mask_format,
|
||||||
INT16 x_src, INT16 y_src,
|
INT16 x_src, INT16 y_src,
|
||||||
int ntrap, xTrapezoid * traps);
|
int ntrap, xTrapezoid *traps);
|
||||||
|
|
||||||
extern _X_EXPORT Bool glamor_glyphs_nf(CARD8 op,
|
extern _X_EXPORT Bool glamor_glyphs_nf(CARD8 op,
|
||||||
PicturePtr src,
|
PicturePtr src,
|
||||||
PicturePtr dst,
|
PicturePtr dst,
|
||||||
PictFormatPtr mask_format,
|
PictFormatPtr mask_format,
|
||||||
INT16 x_src,
|
INT16 x_src,
|
||||||
INT16 y_src, int nlist,
|
INT16 y_src, int nlist,
|
||||||
GlyphListPtr list, GlyphPtr * glyphs);
|
GlyphListPtr list, GlyphPtr *glyphs);
|
||||||
|
|
||||||
extern _X_EXPORT Bool glamor_triangles_nf(CARD8 op,
|
extern _X_EXPORT Bool glamor_triangles_nf(CARD8 op,
|
||||||
PicturePtr pSrc,
|
PicturePtr pSrc,
|
||||||
PicturePtr pDst,
|
PicturePtr pDst,
|
||||||
PictFormatPtr maskFormat,
|
PictFormatPtr maskFormat,
|
||||||
INT16 xSrc, INT16 ySrc,
|
INT16 xSrc, INT16 ySrc,
|
||||||
int ntris, xTriangle * tris);
|
int ntris, xTriangle *tris);
|
||||||
|
|
||||||
|
|
||||||
extern _X_EXPORT void glamor_glyph_unrealize(ScreenPtr screen, GlyphPtr glyph);
|
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,
|
extern _X_EXPORT Bool glamor_set_spans_nf(DrawablePtr drawable, GCPtr gc,
|
||||||
DDXPointPtr points, int *widths, int n, int sorted);
|
char *src, DDXPointPtr points,
|
||||||
|
int *widths, int n, int sorted);
|
||||||
|
|
||||||
extern _X_EXPORT Bool glamor_get_spans_nf(DrawablePtr drawable, int wmax,
|
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,
|
extern _X_EXPORT Bool glamor_composite_rects_nf(CARD8 op,
|
||||||
PicturePtr pDst,
|
PicturePtr pDst,
|
||||||
xRenderColor *color,
|
xRenderColor *color,
|
||||||
int nRect,
|
int nRect, xRectangle *rects);
|
||||||
xRectangle *rects);
|
|
||||||
|
|
||||||
extern _X_EXPORT Bool glamor_get_image_nf(DrawablePtr pDrawable, int x, int y, int w, int h,
|
extern _X_EXPORT Bool glamor_get_image_nf(DrawablePtr pDrawable, int x, int y,
|
||||||
unsigned int format, unsigned long planeMask, char *d);
|
int w, int h, unsigned int format,
|
||||||
|
unsigned long planeMask, char *d);
|
||||||
|
|
||||||
extern _X_EXPORT Bool glamor_add_traps_nf(PicturePtr pPicture,
|
extern _X_EXPORT Bool glamor_add_traps_nf(PicturePtr pPicture,
|
||||||
INT16 x_off,
|
INT16 x_off,
|
||||||
INT16 y_off, int ntrap, xTrap * traps);
|
INT16 y_off, int ntrap,
|
||||||
|
xTrap *traps);
|
||||||
|
|
||||||
extern _X_EXPORT Bool glamor_copy_plane_nf(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
|
extern _X_EXPORT Bool glamor_copy_plane_nf(DrawablePtr pSrc, DrawablePtr pDst,
|
||||||
int srcx, int srcy, int w, int h, int dstx, int dsty,
|
GCPtr pGC, int srcx, int srcy, int w,
|
||||||
unsigned long bitPlane, RegionPtr *pRegion);
|
int h, int dstx, int dsty,
|
||||||
|
unsigned long bitPlane,
|
||||||
|
RegionPtr *pRegion);
|
||||||
|
|
||||||
extern _X_EXPORT Bool glamor_image_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
|
extern _X_EXPORT Bool glamor_image_glyph_blt_nf(DrawablePtr pDrawable,
|
||||||
int x, int y, unsigned int nglyph,
|
GCPtr pGC, int x, int y,
|
||||||
CharInfoPtr * ppci, pointer pglyphBase);
|
unsigned int nglyph,
|
||||||
|
CharInfoPtr *ppci,
|
||||||
|
void *pglyphBase);
|
||||||
|
|
||||||
extern _X_EXPORT Bool glamor_poly_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
|
extern _X_EXPORT Bool glamor_poly_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||||
int x, int y, unsigned int nglyph,
|
int x, int y,
|
||||||
CharInfoPtr * ppci, pointer pglyphBase);
|
unsigned int nglyph,
|
||||||
|
CharInfoPtr *ppci,
|
||||||
|
void *pglyphBase);
|
||||||
|
|
||||||
extern _X_EXPORT Bool glamor_push_pixels_nf(GCPtr pGC, PixmapPtr pBitmap,
|
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,
|
extern _X_EXPORT Bool glamor_poly_point_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||||
DDXPointPtr ppt);
|
int mode, int npt, DDXPointPtr ppt);
|
||||||
|
|
||||||
extern _X_EXPORT Bool glamor_poly_segment_nf(DrawablePtr pDrawable, GCPtr pGC, int nseg,
|
extern _X_EXPORT Bool glamor_poly_segment_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||||
xSegment *pSeg);
|
int nseg, xSegment *pSeg);
|
||||||
|
|
||||||
extern _X_EXPORT Bool glamor_poly_line_nf(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
extern _X_EXPORT Bool glamor_poly_line_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||||
DDXPointPtr ppt);
|
int mode, int npt, DDXPointPtr ppt);
|
||||||
|
|
||||||
extern _X_EXPORT Bool glamor_poly_lines_nf(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
extern _X_EXPORT Bool glamor_poly_lines_nf(DrawablePtr drawable, GCPtr gc,
|
||||||
DDXPointPtr points);
|
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
|
static Bool
|
||||||
_glamor_add_traps(PicturePtr pPicture,
|
_glamor_add_traps(PicturePtr pPicture,
|
||||||
INT16 x_off,
|
INT16 x_off,
|
||||||
INT16 y_off, int ntrap, xTrap * traps,
|
INT16 y_off, int ntrap, xTrap *traps, Bool fallback)
|
||||||
Bool fallback)
|
|
||||||
{
|
{
|
||||||
if (!fallback
|
if (!fallback
|
||||||
&& ( !pPicture->pDrawable
|
&& (!pPicture->pDrawable
|
||||||
|| glamor_ddx_fallback_check_pixmap(pPicture->pDrawable)))
|
|| glamor_ddx_fallback_check_pixmap(pPicture->pDrawable)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (glamor_prepare_access_picture(pPicture, GLAMOR_ACCESS_RW)) {
|
if (glamor_prepare_access_picture(pPicture, GLAMOR_ACCESS_RW)) {
|
||||||
fbAddTraps(pPicture, x_off, y_off, ntrap, traps);
|
fbAddTraps(pPicture, x_off, y_off, ntrap, traps);
|
||||||
glamor_finish_access_picture(pPicture, GLAMOR_ACCESS_RW);
|
glamor_finish_access_picture(pPicture, GLAMOR_ACCESS_RW);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_add_traps(PicturePtr pPicture,
|
glamor_add_traps(PicturePtr pPicture,
|
||||||
INT16 x_off,
|
INT16 x_off, INT16 y_off, int ntrap, xTrap *traps)
|
||||||
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
|
Bool
|
||||||
glamor_add_traps_nf(PicturePtr pPicture,
|
glamor_add_traps_nf(PicturePtr pPicture,
|
||||||
INT16 x_off,
|
INT16 x_off, INT16 y_off, int ntrap, xTrap *traps)
|
||||||
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
|
* 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;
|
int v = (int) a + (int) b;
|
||||||
if (v > MAXSHORT)
|
|
||||||
return MAXSHORT;
|
if (v > MAXSHORT)
|
||||||
return v;
|
return MAXSHORT;
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
_pixman_region_init_clipped_rectangles(pixman_region16_t *region,
|
_pixman_region_init_clipped_rectangles(pixman_region16_t * region,
|
||||||
unsigned int num_rects,
|
unsigned int num_rects,
|
||||||
xRectangle *rects,
|
xRectangle *rects,
|
||||||
int tx, int ty,
|
int tx, int ty, BoxPtr extents)
|
||||||
BoxPtr extents)
|
|
||||||
{
|
{
|
||||||
pixman_box16_t stack_boxes[64], *boxes = stack_boxes;
|
pixman_box16_t stack_boxes[64], *boxes = stack_boxes;
|
||||||
pixman_bool_t ret;
|
pixman_bool_t ret;
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
|
|
||||||
if (num_rects > ARRAY_SIZE(stack_boxes)) {
|
if (num_rects > ARRAY_SIZE(stack_boxes)) {
|
||||||
boxes = malloc(sizeof(pixman_box16_t) * num_rects);
|
boxes = malloc(sizeof(pixman_box16_t) * num_rects);
|
||||||
if (boxes == NULL)
|
if (boxes == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = j = 0; i < num_rects; i++) {
|
for (i = j = 0; i < num_rects; i++) {
|
||||||
boxes[j].x1 = rects[i].x + tx;
|
boxes[j].x1 = rects[i].x + tx;
|
||||||
if (boxes[j].x1 < extents->x1)
|
if (boxes[j].x1 < extents->x1)
|
||||||
boxes[j].x1 = extents->x1;
|
boxes[j].x1 = extents->x1;
|
||||||
|
|
||||||
boxes[j].y1 = rects[i].y + ty;
|
boxes[j].y1 = rects[i].y + ty;
|
||||||
if (boxes[j].y1 < extents->y1)
|
if (boxes[j].y1 < extents->y1)
|
||||||
boxes[j].y1 = extents->y1;
|
boxes[j].y1 = extents->y1;
|
||||||
|
|
||||||
boxes[j].x2 = bound(rects[i].x + tx, rects[i].width);
|
boxes[j].x2 = bound(rects[i].x + tx, rects[i].width);
|
||||||
if (boxes[j].x2 > extents->x2)
|
if (boxes[j].x2 > extents->x2)
|
||||||
boxes[j].x2 = extents->x2;
|
boxes[j].x2 = extents->x2;
|
||||||
|
|
||||||
boxes[j].y2 = bound(rects[i].y + ty, rects[i].height);
|
boxes[j].y2 = bound(rects[i].y + ty, rects[i].height);
|
||||||
if (boxes[j].y2 > extents->y2)
|
if (boxes[j].y2 > extents->y2)
|
||||||
boxes[j].y2 = extents->y2;
|
boxes[j].y2 = extents->y2;
|
||||||
|
|
||||||
if (boxes[j].x2 > boxes[j].x1 && boxes[j].y2 > boxes[j].y1)
|
if (boxes[j].x2 > boxes[j].x1 && boxes[j].y2 > boxes[j].y1)
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
if (j)
|
if (j)
|
||||||
ret = pixman_region_init_rects(region, boxes, j);
|
ret = pixman_region_init_rects(region, boxes, j);
|
||||||
|
|
||||||
if (boxes != stack_boxes)
|
if (boxes != stack_boxes)
|
||||||
free(boxes);
|
free(boxes);
|
||||||
|
|
||||||
DEBUGF("%s: nrects=%d, region=(%d, %d), (%d, %d) x %d\n",
|
DEBUGF("%s: nrects=%d, region=(%d, %d), (%d, %d) x %d\n",
|
||||||
__FUNCTION__, num_rects,
|
__FUNCTION__, num_rects,
|
||||||
region->extents.x1, region->extents.y1,
|
region->extents.x1, region->extents.y1,
|
||||||
region->extents.x2, region->extents.y2,
|
region->extents.x2, region->extents.y2, j);
|
||||||
j);
|
return ret;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_composite_rectangles(CARD8 op,
|
glamor_composite_rectangles(CARD8 op,
|
||||||
PicturePtr dst,
|
PicturePtr dst,
|
||||||
xRenderColor *color,
|
xRenderColor * color,
|
||||||
int num_rects,
|
int num_rects, xRectangle *rects)
|
||||||
xRectangle *rects)
|
|
||||||
{
|
{
|
||||||
PixmapPtr pixmap;
|
PixmapPtr pixmap;
|
||||||
struct glamor_pixmap_private *priv;
|
struct glamor_pixmap_private *priv;
|
||||||
pixman_region16_t region;
|
pixman_region16_t region;
|
||||||
pixman_box16_t *boxes;
|
pixman_box16_t *boxes;
|
||||||
int dst_x, dst_y;
|
int dst_x, dst_y;
|
||||||
int num_boxes;
|
int num_boxes;
|
||||||
PicturePtr source = NULL;
|
PicturePtr source = NULL;
|
||||||
Bool need_free_region = FALSE;
|
Bool need_free_region = FALSE;
|
||||||
|
|
||||||
DEBUGF("%s(op=%d, %08x x %d [(%d, %d)x(%d, %d) ...])\n",
|
DEBUGF("%s(op=%d, %08x x %d [(%d, %d)x(%d, %d) ...])\n",
|
||||||
__FUNCTION__, op,
|
__FUNCTION__, op,
|
||||||
(color->alpha >> 8 << 24) |
|
(color->alpha >> 8 << 24) |
|
||||||
(color->red >> 8 << 16) |
|
(color->red >> 8 << 16) |
|
||||||
(color->green >> 8 << 8) |
|
(color->green >> 8 << 8) |
|
||||||
(color->blue >> 8 << 0),
|
(color->blue >> 8 << 0),
|
||||||
num_rects,
|
num_rects, rects[0].x, rects[0].y, rects[0].width, rects[0].height);
|
||||||
rects[0].x, rects[0].y, rects[0].width, rects[0].height);
|
|
||||||
|
|
||||||
if (!num_rects)
|
if (!num_rects)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (region_is_empty(dst->pCompositeClip)) {
|
if (RegionNil(dst->pCompositeClip)) {
|
||||||
DEBUGF("%s: empty clip, skipping\n", __FUNCTION__);
|
DEBUGF("%s: empty clip, skipping\n", __FUNCTION__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((color->red|color->green|color->blue|color->alpha) <= 0x00ff) {
|
if ((color->red | color->green | color->blue | color->alpha) <= 0x00ff) {
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case PictOpOver:
|
case PictOpOver:
|
||||||
case PictOpOutReverse:
|
case PictOpOutReverse:
|
||||||
case PictOpAdd:
|
case PictOpAdd:
|
||||||
return;
|
return;
|
||||||
case PictOpInReverse:
|
case PictOpInReverse:
|
||||||
case PictOpSrc:
|
case PictOpSrc:
|
||||||
op = PictOpClear;
|
op = PictOpClear;
|
||||||
break;
|
break;
|
||||||
case PictOpAtopReverse:
|
case PictOpAtopReverse:
|
||||||
op = PictOpOut;
|
op = PictOpOut;
|
||||||
break;
|
break;
|
||||||
case PictOpXor:
|
case PictOpXor:
|
||||||
op = PictOpOverReverse;
|
op = PictOpOverReverse;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (color->alpha <= 0x00ff) {
|
if (color->alpha <= 0x00ff) {
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case PictOpOver:
|
case PictOpOver:
|
||||||
case PictOpOutReverse:
|
case PictOpOutReverse:
|
||||||
return;
|
return;
|
||||||
case PictOpInReverse:
|
case PictOpInReverse:
|
||||||
op = PictOpClear;
|
op = PictOpClear;
|
||||||
break;
|
break;
|
||||||
case PictOpAtopReverse:
|
case PictOpAtopReverse:
|
||||||
op = PictOpOut;
|
op = PictOpOut;
|
||||||
break;
|
break;
|
||||||
case PictOpXor:
|
case PictOpXor:
|
||||||
op = PictOpOverReverse;
|
op = PictOpOverReverse;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (color->alpha >= 0xff00) {
|
}
|
||||||
switch (op) {
|
else if (color->alpha >= 0xff00) {
|
||||||
case PictOpOver:
|
switch (op) {
|
||||||
op = PictOpSrc;
|
case PictOpOver:
|
||||||
break;
|
op = PictOpSrc;
|
||||||
case PictOpInReverse:
|
break;
|
||||||
return;
|
case PictOpInReverse:
|
||||||
case PictOpOutReverse:
|
return;
|
||||||
op = PictOpClear;
|
case PictOpOutReverse:
|
||||||
break;
|
op = PictOpClear;
|
||||||
case PictOpAtopReverse:
|
break;
|
||||||
op = PictOpOverReverse;
|
case PictOpAtopReverse:
|
||||||
break;
|
op = PictOpOverReverse;
|
||||||
case PictOpXor:
|
break;
|
||||||
op = PictOpOut;
|
case PictOpXor:
|
||||||
break;
|
op = PictOpOut;
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
DEBUGF("%s: converted to op %d\n", __FUNCTION__, op);
|
}
|
||||||
|
DEBUGF("%s: converted to op %d\n", __FUNCTION__, op);
|
||||||
|
|
||||||
if (!_pixman_region_init_clipped_rectangles(®ion,
|
if (!_pixman_region_init_clipped_rectangles(®ion,
|
||||||
num_rects, rects,
|
num_rects, rects,
|
||||||
dst->pDrawable->x,
|
dst->pDrawable->x,
|
||||||
dst->pDrawable->y,
|
dst->pDrawable->y,
|
||||||
&dst->pCompositeClip->extents))
|
&dst->pCompositeClip->extents))
|
||||||
{
|
{
|
||||||
DEBUGF("%s: allocation failed for region\n", __FUNCTION__);
|
DEBUGF("%s: allocation failed for region\n", __FUNCTION__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pixmap = glamor_get_drawable_pixmap(dst->pDrawable);
|
pixmap = glamor_get_drawable_pixmap(dst->pDrawable);
|
||||||
priv = glamor_get_pixmap_private(pixmap);
|
priv = glamor_get_pixmap_private(pixmap);
|
||||||
|
|
||||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(priv))
|
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(priv))
|
||||||
goto fallback;
|
goto fallback;
|
||||||
if (dst->alphaMap) {
|
if (dst->alphaMap) {
|
||||||
DEBUGF("%s: fallback, dst has an alpha-map\n", __FUNCTION__);
|
DEBUGF("%s: fallback, dst has an alpha-map\n", __FUNCTION__);
|
||||||
goto fallback;
|
goto fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
need_free_region = TRUE;
|
need_free_region = TRUE;
|
||||||
|
|
||||||
DEBUGF("%s: drawable extents (%d, %d),(%d, %d) x %d\n",
|
DEBUGF("%s: drawable extents (%d, %d),(%d, %d) x %d\n",
|
||||||
__FUNCTION__,
|
__FUNCTION__,
|
||||||
RegionExtents(®ion)->x1, RegionExtents(®ion)->y1,
|
RegionExtents(®ion)->x1, RegionExtents(®ion)->y1,
|
||||||
RegionExtents(®ion)->x2, RegionExtents(®ion)->y2,
|
RegionExtents(®ion)->x2, RegionExtents(®ion)->y2,
|
||||||
RegionNumRects(®ion));
|
RegionNumRects(®ion));
|
||||||
|
|
||||||
if (dst->pCompositeClip->data &&
|
if (dst->pCompositeClip->data &&
|
||||||
(!pixman_region_intersect(®ion, ®ion, dst->pCompositeClip) ||
|
(!pixman_region_intersect(®ion, ®ion, dst->pCompositeClip) ||
|
||||||
region_is_empty(®ion))) {
|
RegionNil(®ion))) {
|
||||||
DEBUGF("%s: zero-intersection between rectangles and clip\n",
|
DEBUGF("%s: zero-intersection between rectangles and clip\n",
|
||||||
__FUNCTION__);
|
__FUNCTION__);
|
||||||
pixman_region_fini(®ion);
|
pixman_region_fini(®ion);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGF("%s: clipped extents (%d, %d),(%d, %d) x %d\n",
|
DEBUGF("%s: clipped extents (%d, %d),(%d, %d) x %d\n",
|
||||||
__FUNCTION__,
|
__FUNCTION__,
|
||||||
RegionExtents(®ion)->x1, RegionExtents(®ion)->y1,
|
RegionExtents(®ion)->x1, RegionExtents(®ion)->y1,
|
||||||
RegionExtents(®ion)->x2, RegionExtents(®ion)->y2,
|
RegionExtents(®ion)->x2, RegionExtents(®ion)->y2,
|
||||||
RegionNumRects(®ion));
|
RegionNumRects(®ion));
|
||||||
|
|
||||||
glamor_get_drawable_deltas(dst->pDrawable, pixmap, &dst_x, &dst_y);
|
glamor_get_drawable_deltas(dst->pDrawable, pixmap, &dst_x, &dst_y);
|
||||||
pixman_region_translate(®ion, dst_x, dst_y);
|
pixman_region_translate(®ion, dst_x, dst_y);
|
||||||
|
|
||||||
DEBUGF("%s: pixmap +(%d, %d) extents (%d, %d),(%d, %d)\n",
|
DEBUGF("%s: pixmap +(%d, %d) extents (%d, %d),(%d, %d)\n",
|
||||||
__FUNCTION__, dst_x, dst_y,
|
__FUNCTION__, dst_x, dst_y,
|
||||||
RegionExtents(®ion)->x1, RegionExtents(®ion)->y1,
|
RegionExtents(®ion)->x1, RegionExtents(®ion)->y1,
|
||||||
RegionExtents(®ion)->x2, RegionExtents(®ion)->y2);
|
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 == PictOpClear)
|
||||||
if (op == PictOpSrc || op == PictOpClear) {
|
pixel = 0;
|
||||||
CARD32 pixel;
|
else
|
||||||
if (op == PictOpClear)
|
miRenderColorToPixel(dst->pFormat, color, &pixel);
|
||||||
pixel = 0;
|
glamor_solid_boxes(pixmap, boxes, num_boxes, pixel);
|
||||||
else
|
|
||||||
miRenderColorToPixel(dst->pFormat, color, &pixel);
|
|
||||||
glamor_solid_boxes(pixmap, boxes, num_boxes, pixel);
|
|
||||||
|
|
||||||
goto done;
|
goto done;
|
||||||
} else {
|
}
|
||||||
if (likely(priv->type != GLAMOR_TEXTURE_LARGE)) {
|
else {
|
||||||
int error;
|
if (_X_LIKELY(priv->type != GLAMOR_TEXTURE_LARGE)) {
|
||||||
|
int error;
|
||||||
|
|
||||||
source = CreateSolidPicture(0, color, &error);
|
source = CreateSolidPicture(0, color, &error);
|
||||||
if (!source)
|
if (!source)
|
||||||
goto done;
|
goto done;
|
||||||
if (glamor_composite_clipped_region(op, source,
|
if (glamor_composite_clipped_region(op, source,
|
||||||
NULL, dst,
|
NULL, dst,
|
||||||
NULL, NULL, priv,
|
NULL, NULL, priv,
|
||||||
®ion,
|
®ion, 0, 0, 0, 0, 0, 0))
|
||||||
0,0,0,0,0,0))
|
goto done;
|
||||||
goto done;
|
}
|
||||||
}
|
}
|
||||||
}
|
fallback:
|
||||||
fallback:
|
miCompositeRects(op, dst, color, num_rects, rects);
|
||||||
miCompositeRects(op, dst, color, num_rects, rects);
|
done:
|
||||||
done:
|
/* XXX xserver-1.8: CompositeRects is not tracked by Damage, so we must
|
||||||
/* XXX xserver-1.8: CompositeRects is not tracked by Damage, so we must
|
* manually append the damaged regions ourselves.
|
||||||
* manually append the damaged regions ourselves.
|
*/
|
||||||
*/
|
DamageRegionAppend(&pixmap->drawable, ®ion);
|
||||||
DamageRegionAppend(&pixmap->drawable, ®ion);
|
DamageRegionProcessPending(&pixmap->drawable);
|
||||||
DamageRegionProcessPending(&pixmap->drawable);
|
|
||||||
|
|
||||||
if (need_free_region)
|
if (need_free_region)
|
||||||
pixman_region_fini(®ion);
|
pixman_region_fini(®ion);
|
||||||
if (source)
|
if (source)
|
||||||
FreePicture(source, 0);
|
FreePicture(source, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -30,43 +30,43 @@
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
_glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
|
_glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
|
||||||
int srcx, int srcy, int w, int h, int dstx, int dsty,
|
int srcx, int srcy, int w, int h, int dstx, int dsty,
|
||||||
unsigned long bitPlane, RegionPtr *pRegion, Bool fallback)
|
unsigned long bitPlane, RegionPtr *pRegion, Bool fallback)
|
||||||
{
|
{
|
||||||
if (!fallback
|
if (!fallback && glamor_ddx_fallback_check_gc(pGC)
|
||||||
&& glamor_ddx_fallback_check_gc(pGC)
|
&& glamor_ddx_fallback_check_pixmap(pSrc)
|
||||||
&& glamor_ddx_fallback_check_pixmap(pSrc)
|
&& glamor_ddx_fallback_check_pixmap(pDst))
|
||||||
&& glamor_ddx_fallback_check_pixmap(pDst))
|
goto fail;
|
||||||
goto fail;
|
|
||||||
|
|
||||||
glamor_prepare_access(pDst, GLAMOR_ACCESS_RW);
|
glamor_prepare_access(pDst, GLAMOR_ACCESS_RW);
|
||||||
glamor_prepare_access(pSrc, GLAMOR_ACCESS_RO);
|
glamor_prepare_access(pSrc, GLAMOR_ACCESS_RO);
|
||||||
*pRegion = fbCopyPlane(pSrc, pDst, pGC, srcx, srcy, w, h,
|
*pRegion = fbCopyPlane(pSrc, pDst, pGC, srcx, srcy, w, h,
|
||||||
dstx, dsty, bitPlane);
|
dstx, dsty, bitPlane);
|
||||||
glamor_finish_access(pSrc, GLAMOR_ACCESS_RO);
|
glamor_finish_access(pSrc, GLAMOR_ACCESS_RO);
|
||||||
glamor_finish_access(pDst, GLAMOR_ACCESS_RW);
|
glamor_finish_access(pDst, GLAMOR_ACCESS_RW);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegionPtr
|
RegionPtr
|
||||||
glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
|
glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
|
||||||
int srcx, int srcy, int w, int h, int dstx, int dsty,
|
int srcx, int srcy, int w, int h, int dstx, int dsty,
|
||||||
unsigned long bitPlane)
|
unsigned long bitPlane)
|
||||||
{
|
{
|
||||||
RegionPtr ret;
|
RegionPtr ret;
|
||||||
_glamor_copy_plane(pSrc, pDst, pGC, srcx, srcy, w, h,
|
|
||||||
dstx, dsty, bitPlane, &ret, TRUE);
|
_glamor_copy_plane(pSrc, pDst, pGC, srcx, srcy, w, h,
|
||||||
return ret;
|
dstx, dsty, bitPlane, &ret, TRUE);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
glamor_copy_plane_nf(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
|
glamor_copy_plane_nf(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
|
||||||
int srcx, int srcy, int w, int h, int dstx, int dsty,
|
int srcx, int srcy, int w, int h, int dstx, int dsty,
|
||||||
unsigned long bitPlane, RegionPtr *pRegion)
|
unsigned long bitPlane, RegionPtr *pRegion)
|
||||||
{
|
{
|
||||||
return _glamor_copy_plane(pSrc, pDst, pGC, srcx, srcy, w, h,
|
return _glamor_copy_plane(pSrc, pDst, pGC, srcx, srcy, w, h,
|
||||||
dstx, dsty, bitPlane, pRegion, FALSE);
|
dstx, dsty, bitPlane, pRegion, FALSE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,30 +29,28 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_copy_window(WindowPtr win, DDXPointRec old_origin,
|
glamor_copy_window(WindowPtr win, DDXPointRec old_origin, RegionPtr src_region)
|
||||||
RegionPtr src_region)
|
|
||||||
{
|
{
|
||||||
RegionRec dst_region;
|
RegionRec dst_region;
|
||||||
int dx, dy;
|
int dx, dy;
|
||||||
PixmapPtr pixmap = win->drawable.pScreen->GetWindowPixmap(win);
|
PixmapPtr pixmap = win->drawable.pScreen->GetWindowPixmap(win);
|
||||||
|
|
||||||
dx = old_origin.x - win->drawable.x;
|
dx = old_origin.x - win->drawable.x;
|
||||||
dy = old_origin.y - win->drawable.y;
|
dy = old_origin.y - win->drawable.y;
|
||||||
REGION_TRANSLATE(win->drawable.pScreen, src_region, -dx, -dy);
|
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,
|
REGION_INTERSECT(win->drawable.pScreen, &dst_region,
|
||||||
&win->borderClip, src_region);
|
&win->borderClip, src_region);
|
||||||
#ifdef COMPOSITE
|
#ifdef COMPOSITE
|
||||||
if (pixmap->screen_x || pixmap->screen_y)
|
if (pixmap->screen_x || pixmap->screen_y)
|
||||||
REGION_TRANSLATE(win->drawable.pScreen, &dst_region,
|
REGION_TRANSLATE(win->drawable.pScreen, &dst_region,
|
||||||
-pixmap->screen_x, -pixmap->screen_y);
|
-pixmap->screen_x, -pixmap->screen_y);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
miCopyRegion(&pixmap->drawable, &pixmap->drawable,
|
miCopyRegion(&pixmap->drawable, &pixmap->drawable,
|
||||||
NULL, &dst_region, dx, dy, glamor_copy_n_to_n, 0,
|
NULL, &dst_region, dx, dy, glamor_copy_n_to_n, 0, NULL);
|
||||||
NULL);
|
|
||||||
|
|
||||||
REGION_UNINIT(win->drawable.pScreen, &dst_region);
|
REGION_UNINIT(win->drawable.pScreen, &dst_region);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,76 +38,76 @@
|
||||||
const Bool
|
const Bool
|
||||||
glamor_get_drawable_location(const DrawablePtr drawable)
|
glamor_get_drawable_location(const DrawablePtr drawable)
|
||||||
{
|
{
|
||||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||||
glamor_pixmap_private *pixmap_priv =
|
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||||
glamor_get_pixmap_private(pixmap);
|
glamor_screen_private *glamor_priv =
|
||||||
glamor_screen_private *glamor_priv =
|
glamor_get_screen_private(drawable->pScreen);
|
||||||
glamor_get_screen_private(drawable->pScreen);
|
if (pixmap_priv == NULL || pixmap_priv->base.gl_fbo == 0)
|
||||||
if (pixmap_priv == NULL || pixmap_priv->base.gl_fbo == 0)
|
return 'm';
|
||||||
return 'm';
|
if (pixmap_priv->base.fbo->fb == glamor_priv->screen_fbo)
|
||||||
if (pixmap_priv->base.fbo->fb == glamor_priv->screen_fbo)
|
return 's';
|
||||||
return 's';
|
else
|
||||||
else
|
return 'f';
|
||||||
return 'f';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLint
|
GLint
|
||||||
glamor_compile_glsl_prog(glamor_gl_dispatch * dispatch, GLenum type,
|
glamor_compile_glsl_prog(glamor_gl_dispatch * dispatch, GLenum type,
|
||||||
const char *source)
|
const char *source)
|
||||||
{
|
{
|
||||||
GLint ok;
|
GLint ok;
|
||||||
GLint prog;
|
GLint prog;
|
||||||
|
|
||||||
prog = dispatch->glCreateShader(type);
|
prog = dispatch->glCreateShader(type);
|
||||||
dispatch->glShaderSource(prog, 1, (const GLchar **) &source, NULL);
|
dispatch->glShaderSource(prog, 1, (const GLchar **) &source, NULL);
|
||||||
dispatch->glCompileShader(prog);
|
dispatch->glCompileShader(prog);
|
||||||
dispatch->glGetShaderiv(prog, GL_COMPILE_STATUS, &ok);
|
dispatch->glGetShaderiv(prog, GL_COMPILE_STATUS, &ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
GLchar *info;
|
GLchar *info;
|
||||||
GLint size;
|
GLint size;
|
||||||
|
|
||||||
dispatch->glGetShaderiv(prog, GL_INFO_LOG_LENGTH, &size);
|
dispatch->glGetShaderiv(prog, GL_INFO_LOG_LENGTH, &size);
|
||||||
info = malloc(size);
|
info = malloc(size);
|
||||||
if (info) {
|
if (info) {
|
||||||
dispatch->glGetShaderInfoLog(prog, size, NULL, info);
|
dispatch->glGetShaderInfoLog(prog, size, NULL, info);
|
||||||
ErrorF("Failed to compile %s: %s\n",
|
ErrorF("Failed to compile %s: %s\n",
|
||||||
type == GL_FRAGMENT_SHADER ? "FS" : "VS", info);
|
type == GL_FRAGMENT_SHADER ? "FS" : "VS", info);
|
||||||
ErrorF("Program source:\n%s", source);
|
ErrorF("Program source:\n%s", source);
|
||||||
free(info);
|
free(info);
|
||||||
} else
|
}
|
||||||
ErrorF("Failed to get shader compilation info.\n");
|
else
|
||||||
FatalError("GLSL compile failure\n");
|
ErrorF("Failed to get shader compilation info.\n");
|
||||||
}
|
FatalError("GLSL compile failure\n");
|
||||||
|
}
|
||||||
|
|
||||||
return prog;
|
return prog;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_link_glsl_prog(glamor_gl_dispatch * dispatch, GLint prog)
|
glamor_link_glsl_prog(glamor_gl_dispatch * dispatch, GLint prog)
|
||||||
{
|
{
|
||||||
GLint ok;
|
GLint ok;
|
||||||
|
|
||||||
dispatch->glLinkProgram(prog);
|
dispatch->glLinkProgram(prog);
|
||||||
dispatch->glGetProgramiv(prog, GL_LINK_STATUS, &ok);
|
dispatch->glGetProgramiv(prog, GL_LINK_STATUS, &ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
GLchar *info;
|
GLchar *info;
|
||||||
GLint size;
|
GLint size;
|
||||||
|
|
||||||
dispatch->glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &size);
|
dispatch->glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &size);
|
||||||
info = malloc(size);
|
info = malloc(size);
|
||||||
|
|
||||||
dispatch->glGetProgramInfoLog(prog, size, NULL, info);
|
dispatch->glGetProgramInfoLog(prog, size, NULL, info);
|
||||||
ErrorF("Failed to link: %s\n", info);
|
ErrorF("Failed to link: %s\n", info);
|
||||||
FatalError("GLSL link failure\n");
|
FatalError("GLSL link failure\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
glamor_prepare_access(DrawablePtr drawable, glamor_access_t access)
|
glamor_prepare_access(DrawablePtr drawable, glamor_access_t access)
|
||||||
{
|
{
|
||||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||||
return glamor_download_pixmap_to_cpu(pixmap, access);
|
|
||||||
|
return glamor_download_pixmap_to_cpu(pixmap, access);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -142,221 +142,205 @@ glamor_prepare_access(DrawablePtr drawable, glamor_access_t access)
|
||||||
void
|
void
|
||||||
glamor_init_finish_access_shaders(ScreenPtr screen)
|
glamor_init_finish_access_shaders(ScreenPtr screen)
|
||||||
{
|
{
|
||||||
glamor_screen_private *glamor_priv;
|
glamor_screen_private *glamor_priv;
|
||||||
glamor_gl_dispatch *dispatch;
|
glamor_gl_dispatch *dispatch;
|
||||||
const char *vs_source =
|
const char *vs_source =
|
||||||
"attribute vec4 v_position;\n"
|
"attribute vec4 v_position;\n"
|
||||||
"attribute vec4 v_texcoord0;\n"
|
"attribute vec4 v_texcoord0;\n"
|
||||||
"varying vec2 source_texture;\n"
|
"varying vec2 source_texture;\n"
|
||||||
"void main()\n"
|
"void main()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" gl_Position = v_position;\n"
|
" gl_Position = v_position;\n"
|
||||||
" source_texture = v_texcoord0.xy;\n" "}\n";
|
" source_texture = v_texcoord0.xy;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
const char *common_source =
|
const char *common_source =
|
||||||
GLAMOR_DEFAULT_PRECISION
|
GLAMOR_DEFAULT_PRECISION
|
||||||
"varying vec2 source_texture;\n"
|
"varying vec2 source_texture;\n"
|
||||||
"uniform sampler2D sampler;\n"
|
"uniform sampler2D sampler;\n"
|
||||||
"uniform int revert;\n"
|
"uniform int revert;\n"
|
||||||
"uniform int swap_rb;\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"
|
const char *fs_source =
|
||||||
"#define REVERT_NORMAL 1\n"
|
"void main()\n"
|
||||||
"#define SWAP_NONE_DOWNLOADING 0\n"
|
"{\n"
|
||||||
"#define SWAP_DOWNLOADING 1\n"
|
" if (revert == REVERT_NONE) \n"
|
||||||
"#define SWAP_UPLOADING 2\n"
|
" { \n"
|
||||||
"#define SWAP_NONE_UPLOADING 3\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 =
|
const char *set_alpha_source =
|
||||||
"void main()\n"
|
"void main()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" if (revert == REVERT_NONE) \n"
|
" if (revert == REVERT_NONE) \n"
|
||||||
" { \n"
|
" { \n"
|
||||||
" if ((swap_rb != SWAP_NONE_DOWNLOADING) && (swap_rb != SWAP_NONE_UPLOADING)) \n"
|
" if ((swap_rb != SWAP_NONE_DOWNLOADING) && (swap_rb != SWAP_NONE_UPLOADING)) \n"
|
||||||
" gl_FragColor = texture2D(sampler, source_texture).bgra;\n"
|
" gl_FragColor = vec4(texture2D(sampler, source_texture).bgr, 1);\n"
|
||||||
" else \n"
|
" else \n"
|
||||||
" gl_FragColor = texture2D(sampler, source_texture).rgba;\n"
|
" gl_FragColor = vec4(texture2D(sampler, source_texture).rgb, 1);\n"
|
||||||
" } \n"
|
" } \n"
|
||||||
" else \n"
|
" else \n"
|
||||||
" { \n"
|
" { \n"
|
||||||
" if (swap_rb == SWAP_DOWNLOADING) \n"
|
" if (swap_rb == SWAP_DOWNLOADING) \n"
|
||||||
" gl_FragColor = texture2D(sampler, source_texture).argb;\n"
|
" gl_FragColor = vec4(1, texture2D(sampler, source_texture).rgb);\n"
|
||||||
" else if (swap_rb == SWAP_NONE_DOWNLOADING)\n"
|
" else if (swap_rb == SWAP_NONE_DOWNLOADING)\n"
|
||||||
" gl_FragColor = texture2D(sampler, source_texture).abgr;\n"
|
" gl_FragColor = vec4(1, texture2D(sampler, source_texture).bgr);\n"
|
||||||
" else if (swap_rb == SWAP_UPLOADING)\n"
|
" else if (swap_rb == SWAP_UPLOADING)\n"
|
||||||
" gl_FragColor = texture2D(sampler, source_texture).gbar;\n"
|
" gl_FragColor = vec4(texture2D(sampler, source_texture).gba, 1);\n"
|
||||||
" else if (swap_rb == SWAP_NONE_UPLOADING)\n"
|
" else if (swap_rb == SWAP_NONE_UPLOADING)\n"
|
||||||
" gl_FragColor = texture2D(sampler, source_texture).abgr;\n"
|
" gl_FragColor = vec4(texture2D(sampler, source_texture).abg, 1);\n"
|
||||||
" } \n" "}\n";
|
" } \n"
|
||||||
|
"}\n";
|
||||||
|
GLint fs_prog, vs_prog, avs_prog, set_alpha_prog;
|
||||||
|
GLint sampler_uniform_location;
|
||||||
|
char *source;
|
||||||
|
|
||||||
const char *set_alpha_source =
|
glamor_priv = glamor_get_screen_private(screen);
|
||||||
"void main()\n"
|
dispatch = glamor_get_dispatch(glamor_priv);
|
||||||
"{\n"
|
glamor_priv->finish_access_prog[0] = dispatch->glCreateProgram();
|
||||||
" if (revert == REVERT_NONE) \n"
|
glamor_priv->finish_access_prog[1] = dispatch->glCreateProgram();
|
||||||
" { \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);
|
vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, vs_source);
|
||||||
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,
|
XNFasprintf(&source, "%s%s", common_source, fs_source);
|
||||||
vs_source);
|
fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER, source);
|
||||||
|
free(source);
|
||||||
|
|
||||||
XNFasprintf(&source, "%s%s", common_source, fs_source);
|
dispatch->glAttachShader(glamor_priv->finish_access_prog[0], vs_prog);
|
||||||
fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
|
dispatch->glAttachShader(glamor_priv->finish_access_prog[0], fs_prog);
|
||||||
source);
|
|
||||||
free(source);
|
|
||||||
|
|
||||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[0],
|
avs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, vs_source);
|
||||||
vs_prog);
|
|
||||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[0],
|
|
||||||
fs_prog);
|
|
||||||
|
|
||||||
avs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER,
|
XNFasprintf(&source, "%s%s", common_source, set_alpha_source);
|
||||||
vs_source);
|
set_alpha_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
|
||||||
|
source);
|
||||||
|
free(source);
|
||||||
|
|
||||||
XNFasprintf(&source, "%s%s", common_source, set_alpha_source);
|
dispatch->glAttachShader(glamor_priv->finish_access_prog[1], avs_prog);
|
||||||
set_alpha_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
|
dispatch->glAttachShader(glamor_priv->finish_access_prog[1],
|
||||||
source);
|
set_alpha_prog);
|
||||||
free(source);
|
|
||||||
|
|
||||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[1],
|
dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[0],
|
||||||
avs_prog);
|
GLAMOR_VERTEX_POS, "v_position");
|
||||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[1],
|
dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[0],
|
||||||
set_alpha_prog);
|
GLAMOR_VERTEX_SOURCE, "v_texcoord0");
|
||||||
|
glamor_link_glsl_prog(dispatch, glamor_priv->finish_access_prog[0]);
|
||||||
|
|
||||||
dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[0],
|
dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[1],
|
||||||
GLAMOR_VERTEX_POS, "v_position");
|
GLAMOR_VERTEX_POS, "v_position");
|
||||||
dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[0],
|
dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[1],
|
||||||
GLAMOR_VERTEX_SOURCE,
|
GLAMOR_VERTEX_SOURCE, "v_texcoord0");
|
||||||
"v_texcoord0");
|
glamor_link_glsl_prog(dispatch, glamor_priv->finish_access_prog[1]);
|
||||||
glamor_link_glsl_prog(dispatch,
|
|
||||||
glamor_priv->finish_access_prog[0]);
|
|
||||||
|
|
||||||
dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[1],
|
glamor_priv->finish_access_revert[0] =
|
||||||
GLAMOR_VERTEX_POS, "v_position");
|
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[0],
|
||||||
dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[1],
|
"revert");
|
||||||
GLAMOR_VERTEX_SOURCE,
|
|
||||||
"v_texcoord0");
|
|
||||||
glamor_link_glsl_prog(dispatch,
|
|
||||||
glamor_priv->finish_access_prog[1]);
|
|
||||||
|
|
||||||
glamor_priv->finish_access_revert[0] =
|
glamor_priv->finish_access_swap_rb[0] =
|
||||||
dispatch->
|
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[0],
|
||||||
glGetUniformLocation(glamor_priv->finish_access_prog[0],
|
"swap_rb");
|
||||||
"revert");
|
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] =
|
glamor_priv->finish_access_revert[1] =
|
||||||
dispatch->
|
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[1],
|
||||||
glGetUniformLocation(glamor_priv->finish_access_prog[0],
|
"revert");
|
||||||
"swap_rb");
|
glamor_priv->finish_access_swap_rb[1] =
|
||||||
sampler_uniform_location =
|
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[1],
|
||||||
dispatch->
|
"swap_rb");
|
||||||
glGetUniformLocation(glamor_priv->finish_access_prog[0],
|
sampler_uniform_location =
|
||||||
"sampler");
|
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[1],
|
||||||
dispatch->glUseProgram(glamor_priv->finish_access_prog[0]);
|
"sampler");
|
||||||
dispatch->glUniform1i(sampler_uniform_location, 0);
|
dispatch->glUseProgram(glamor_priv->finish_access_prog[1]);
|
||||||
dispatch->glUniform1i(glamor_priv->finish_access_revert[0], 0);
|
dispatch->glUniform1i(glamor_priv->finish_access_revert[1], 0);
|
||||||
dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[0], 0);
|
dispatch->glUniform1i(sampler_uniform_location, 0);
|
||||||
dispatch->glUseProgram(0);
|
dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[1], 0);
|
||||||
|
dispatch->glUseProgram(0);
|
||||||
glamor_priv->finish_access_revert[1] =
|
glamor_put_dispatch(glamor_priv);
|
||||||
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
|
void
|
||||||
glamor_fini_finish_access_shaders(ScreenPtr screen)
|
glamor_fini_finish_access_shaders(ScreenPtr screen)
|
||||||
{
|
{
|
||||||
glamor_screen_private *glamor_priv;
|
glamor_screen_private *glamor_priv;
|
||||||
glamor_gl_dispatch *dispatch;
|
glamor_gl_dispatch *dispatch;
|
||||||
|
|
||||||
glamor_priv = glamor_get_screen_private(screen);
|
glamor_priv = glamor_get_screen_private(screen);
|
||||||
dispatch = glamor_get_dispatch(glamor_priv);
|
dispatch = glamor_get_dispatch(glamor_priv);
|
||||||
dispatch->glDeleteProgram(glamor_priv->finish_access_prog[0]);
|
dispatch->glDeleteProgram(glamor_priv->finish_access_prog[0]);
|
||||||
dispatch->glDeleteProgram(glamor_priv->finish_access_prog[1]);
|
dispatch->glDeleteProgram(glamor_priv->finish_access_prog[1]);
|
||||||
glamor_put_dispatch(glamor_priv);
|
glamor_put_dispatch(glamor_priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_finish_access(DrawablePtr drawable, glamor_access_t access_mode)
|
glamor_finish_access(DrawablePtr drawable, glamor_access_t access_mode)
|
||||||
{
|
{
|
||||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||||
glamor_pixmap_private *pixmap_priv =
|
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||||
glamor_get_pixmap_private(pixmap);
|
glamor_screen_private *glamor_priv =
|
||||||
glamor_screen_private *glamor_priv =
|
glamor_get_screen_private(drawable->pScreen);
|
||||||
glamor_get_screen_private(drawable->pScreen);
|
|
||||||
|
|
||||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO_DOWNLOADED(pixmap_priv))
|
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO_DOWNLOADED(pixmap_priv))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (access_mode != GLAMOR_ACCESS_RO) {
|
if (access_mode != GLAMOR_ACCESS_RO) {
|
||||||
glamor_restore_pixmap_to_texture(pixmap);
|
glamor_restore_pixmap_to_texture(pixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pixmap_priv->base.fbo->pbo != 0 && pixmap_priv->base.fbo->pbo_valid) {
|
if (pixmap_priv->base.fbo->pbo != 0 && pixmap_priv->base.fbo->pbo_valid) {
|
||||||
glamor_gl_dispatch *dispatch;
|
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 = glamor_get_dispatch(glamor_priv);
|
||||||
dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
||||||
dispatch->glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
dispatch->glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||||
dispatch->glDeleteBuffers(1, &pixmap_priv->base.fbo->pbo);
|
dispatch->glDeleteBuffers(1, &pixmap_priv->base.fbo->pbo);
|
||||||
glamor_put_dispatch(glamor_priv);
|
glamor_put_dispatch(glamor_priv);
|
||||||
|
|
||||||
pixmap_priv->base.fbo->pbo_valid = FALSE;
|
pixmap_priv->base.fbo->pbo_valid = FALSE;
|
||||||
pixmap_priv->base.fbo->pbo = 0;
|
pixmap_priv->base.fbo->pbo = 0;
|
||||||
} else {
|
}
|
||||||
free(pixmap->devPrivate.ptr);
|
else {
|
||||||
}
|
free(pixmap->devPrivate.ptr);
|
||||||
|
}
|
||||||
|
|
||||||
if (pixmap_priv->type == GLAMOR_TEXTURE_DRM)
|
if (pixmap_priv->type == GLAMOR_TEXTURE_DRM)
|
||||||
pixmap->devKind = pixmap_priv->base.drm_stride;
|
pixmap->devKind = pixmap_priv->base.drm_stride;
|
||||||
|
|
||||||
if (pixmap_priv->base.gl_fbo == GLAMOR_FBO_DOWNLOADED)
|
if (pixmap_priv->base.gl_fbo == GLAMOR_FBO_DOWNLOADED)
|
||||||
pixmap_priv->base.gl_fbo = GLAMOR_FBO_NORMAL;
|
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
|
* Calls uxa_prepare_access with UXA_PREPARE_SRC for the tile, if that is the
|
||||||
* current fill style.
|
* current fill style.
|
||||||
|
@ -368,22 +352,19 @@ glamor_finish_access(DrawablePtr drawable, glamor_access_t access_mode)
|
||||||
Bool
|
Bool
|
||||||
glamor_prepare_access_gc(GCPtr gc)
|
glamor_prepare_access_gc(GCPtr gc)
|
||||||
{
|
{
|
||||||
if (gc->stipple) {
|
if (gc->stipple) {
|
||||||
if (!glamor_prepare_access
|
if (!glamor_prepare_access(&gc->stipple->drawable, GLAMOR_ACCESS_RO))
|
||||||
(&gc->stipple->drawable, GLAMOR_ACCESS_RO))
|
return FALSE;
|
||||||
return FALSE;
|
}
|
||||||
}
|
if (gc->fillStyle == FillTiled) {
|
||||||
if (gc->fillStyle == FillTiled) {
|
if (!glamor_prepare_access(&gc->tile.pixmap->drawable,
|
||||||
if (!glamor_prepare_access(&gc->tile.pixmap->drawable,
|
GLAMOR_ACCESS_RO)) {
|
||||||
GLAMOR_ACCESS_RO)) {
|
if (gc->stipple)
|
||||||
if (gc->stipple)
|
glamor_finish_access(&gc->stipple->drawable, GLAMOR_ACCESS_RO);
|
||||||
glamor_finish_access(&gc->
|
return FALSE;
|
||||||
stipple->drawable,
|
}
|
||||||
GLAMOR_ACCESS_RO);
|
}
|
||||||
return FALSE;
|
return TRUE;
|
||||||
}
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -392,45 +373,44 @@ glamor_prepare_access_gc(GCPtr gc)
|
||||||
void
|
void
|
||||||
glamor_finish_access_gc(GCPtr gc)
|
glamor_finish_access_gc(GCPtr gc)
|
||||||
{
|
{
|
||||||
if (gc->fillStyle == FillTiled)
|
if (gc->fillStyle == FillTiled)
|
||||||
glamor_finish_access(&gc->tile.pixmap->drawable, GLAMOR_ACCESS_RO);
|
glamor_finish_access(&gc->tile.pixmap->drawable, GLAMOR_ACCESS_RO);
|
||||||
if (gc->stipple)
|
if (gc->stipple)
|
||||||
glamor_finish_access(&gc->stipple->drawable, GLAMOR_ACCESS_RO);
|
glamor_finish_access(&gc->stipple->drawable, GLAMOR_ACCESS_RO);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
glamor_stipple(PixmapPtr pixmap, PixmapPtr stipple,
|
glamor_stipple(PixmapPtr pixmap, PixmapPtr stipple,
|
||||||
int x, int y, int width, int height,
|
int x, int y, int width, int height,
|
||||||
unsigned char alu, unsigned long planemask,
|
unsigned char alu, unsigned long planemask,
|
||||||
unsigned long fg_pixel, unsigned long bg_pixel,
|
unsigned long fg_pixel, unsigned long bg_pixel,
|
||||||
int stipple_x, int stipple_y)
|
int stipple_x, int stipple_y)
|
||||||
{
|
{
|
||||||
glamor_fallback("stubbed out stipple depth %d\n",
|
glamor_fallback("stubbed out stipple depth %d\n", pixmap->drawable.depth);
|
||||||
pixmap->drawable.depth);
|
return FALSE;
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GCOps glamor_gc_ops = {
|
GCOps glamor_gc_ops = {
|
||||||
.FillSpans = glamor_fill_spans,
|
.FillSpans = glamor_fill_spans,
|
||||||
.SetSpans = glamor_set_spans,
|
.SetSpans = glamor_set_spans,
|
||||||
.PutImage = glamor_put_image,
|
.PutImage = glamor_put_image,
|
||||||
.CopyArea = glamor_copy_area,
|
.CopyArea = glamor_copy_area,
|
||||||
.CopyPlane = glamor_copy_plane,
|
.CopyPlane = glamor_copy_plane,
|
||||||
.PolyPoint = glamor_poly_point,
|
.PolyPoint = glamor_poly_point,
|
||||||
.Polylines = glamor_poly_lines,
|
.Polylines = glamor_poly_lines,
|
||||||
.PolySegment = glamor_poly_segment,
|
.PolySegment = glamor_poly_segment,
|
||||||
.PolyRectangle = miPolyRectangle,
|
.PolyRectangle = miPolyRectangle,
|
||||||
.PolyArc = miPolyArc,
|
.PolyArc = miPolyArc,
|
||||||
.FillPolygon = miFillPolygon,
|
.FillPolygon = miFillPolygon,
|
||||||
.PolyFillRect = glamor_poly_fill_rect,
|
.PolyFillRect = glamor_poly_fill_rect,
|
||||||
.PolyFillArc = miPolyFillArc,
|
.PolyFillArc = miPolyFillArc,
|
||||||
.PolyText8 = miPolyText8,
|
.PolyText8 = miPolyText8,
|
||||||
.PolyText16 = miPolyText16,
|
.PolyText16 = miPolyText16,
|
||||||
.ImageText8 = miImageText8,
|
.ImageText8 = miImageText8,
|
||||||
.ImageText16 = miImageText16,
|
.ImageText16 = miImageText16,
|
||||||
.ImageGlyphBlt = glamor_image_glyph_blt, //miImageGlyphBlt,
|
.ImageGlyphBlt = glamor_image_glyph_blt, //miImageGlyphBlt,
|
||||||
.PolyGlyphBlt = glamor_poly_glyph_blt, //miPolyGlyphBlt,
|
.PolyGlyphBlt = glamor_poly_glyph_blt, //miPolyGlyphBlt,
|
||||||
.PushPixels = glamor_push_pixels, //miPushPixels,
|
.PushPixels = glamor_push_pixels, //miPushPixels,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -440,104 +420,94 @@ GCOps glamor_gc_ops = {
|
||||||
void
|
void
|
||||||
glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable)
|
glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable)
|
||||||
{
|
{
|
||||||
/* fbValidateGC will do direct access to pixmaps if the tiling has changed.
|
/* fbValidateGC will do direct access to pixmaps if the tiling has changed.
|
||||||
* Preempt fbValidateGC by doing its work and masking the change out, so
|
* Preempt fbValidateGC by doing its work and masking the change out, so
|
||||||
* that we can do the Prepare/finish_access.
|
* that we can do the Prepare/finish_access.
|
||||||
*/
|
*/
|
||||||
#ifdef FB_24_32BIT
|
#ifdef FB_24_32BIT
|
||||||
if ((changes & GCTile) && fbGetRotatedPixmap(gc)) {
|
if ((changes & GCTile) && fbGetRotatedPixmap(gc)) {
|
||||||
gc->pScreen->DestroyPixmap(fbGetRotatedPixmap(gc));
|
gc->pScreen->DestroyPixmap(fbGetRotatedPixmap(gc));
|
||||||
fbGetRotatedPixmap(gc) = 0;
|
fbGetRotatedPixmap(gc) = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gc->fillStyle == FillTiled) {
|
if (gc->fillStyle == FillTiled) {
|
||||||
PixmapPtr old_tile, new_tile;
|
PixmapPtr old_tile, new_tile;
|
||||||
|
|
||||||
old_tile = gc->tile.pixmap;
|
old_tile = gc->tile.pixmap;
|
||||||
if (old_tile->drawable.bitsPerPixel !=
|
if (old_tile->drawable.bitsPerPixel != drawable->bitsPerPixel) {
|
||||||
drawable->bitsPerPixel) {
|
new_tile = fbGetRotatedPixmap(gc);
|
||||||
new_tile = fbGetRotatedPixmap(gc);
|
if (!new_tile ||
|
||||||
if (!new_tile ||
|
new_tile->drawable.bitsPerPixel != drawable->bitsPerPixel) {
|
||||||
new_tile->drawable.bitsPerPixel !=
|
if (new_tile)
|
||||||
drawable->bitsPerPixel) {
|
gc->pScreen->DestroyPixmap(new_tile);
|
||||||
if (new_tile)
|
/* fb24_32ReformatTile will do direct access of a newly-
|
||||||
gc->pScreen->DestroyPixmap
|
* allocated pixmap.
|
||||||
(new_tile);
|
*/
|
||||||
/* fb24_32ReformatTile will do direct access of a newly-
|
glamor_fallback
|
||||||
* allocated pixmap.
|
("GC %p tile FB_24_32 transformat %p.\n", gc, old_tile);
|
||||||
*/
|
|
||||||
glamor_fallback
|
|
||||||
("GC %p tile FB_24_32 transformat %p.\n",
|
|
||||||
gc, old_tile);
|
|
||||||
|
|
||||||
if (glamor_prepare_access
|
if (glamor_prepare_access
|
||||||
(&old_tile->drawable,
|
(&old_tile->drawable, GLAMOR_ACCESS_RO)) {
|
||||||
GLAMOR_ACCESS_RO)) {
|
new_tile =
|
||||||
new_tile =
|
fb24_32ReformatTile(old_tile, drawable->bitsPerPixel);
|
||||||
fb24_32ReformatTile
|
glamor_finish_access(&old_tile->drawable, GLAMOR_ACCESS_RO);
|
||||||
(old_tile,
|
}
|
||||||
drawable->bitsPerPixel);
|
}
|
||||||
glamor_finish_access
|
if (new_tile) {
|
||||||
(&old_tile->drawable, GLAMOR_ACCESS_RO);
|
fbGetRotatedPixmap(gc) = old_tile;
|
||||||
}
|
gc->tile.pixmap = new_tile;
|
||||||
}
|
changes |= GCTile;
|
||||||
if (new_tile) {
|
}
|
||||||
fbGetRotatedPixmap(gc) = old_tile;
|
}
|
||||||
gc->tile.pixmap = new_tile;
|
}
|
||||||
changes |= GCTile;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
if (changes & GCTile) {
|
if (changes & GCTile) {
|
||||||
if (!gc->tileIsPixel) {
|
if (!gc->tileIsPixel) {
|
||||||
glamor_pixmap_private *pixmap_priv =
|
glamor_pixmap_private *pixmap_priv =
|
||||||
glamor_get_pixmap_private(gc->tile.pixmap);
|
glamor_get_pixmap_private(gc->tile.pixmap);
|
||||||
if ((!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
if ((!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||||
&& FbEvenTile(gc->tile.pixmap->drawable.width *
|
&& FbEvenTile(gc->tile.pixmap->drawable.width *
|
||||||
drawable->bitsPerPixel)) {
|
drawable->bitsPerPixel)) {
|
||||||
glamor_fallback
|
glamor_fallback
|
||||||
("GC %p tile changed %p.\n", gc,
|
("GC %p tile changed %p.\n", gc, gc->tile.pixmap);
|
||||||
gc->tile.pixmap);
|
if (glamor_prepare_access
|
||||||
if (glamor_prepare_access
|
(&gc->tile.pixmap->drawable, GLAMOR_ACCESS_RW)) {
|
||||||
(&gc->tile.pixmap->drawable,
|
fbPadPixmap(gc->tile.pixmap);
|
||||||
GLAMOR_ACCESS_RW)) {
|
glamor_finish_access
|
||||||
fbPadPixmap(gc->tile.pixmap);
|
(&gc->tile.pixmap->drawable, GLAMOR_ACCESS_RW);
|
||||||
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.
|
||||||
/* Mask out the GCTile change notification, now that we've done FB's
|
*/
|
||||||
* job for it.
|
changes &= ~GCTile;
|
||||||
*/
|
}
|
||||||
changes &= ~GCTile;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changes & GCStipple && gc->stipple) {
|
if (changes & GCStipple && gc->stipple) {
|
||||||
/* We can't inline stipple handling like we do for GCTile because
|
/* We can't inline stipple handling like we do for GCTile because
|
||||||
* it sets fbgc privates.
|
* it sets fbgc privates.
|
||||||
*/
|
*/
|
||||||
if (glamor_prepare_access
|
if (glamor_prepare_access(&gc->stipple->drawable, GLAMOR_ACCESS_RW)) {
|
||||||
(&gc->stipple->drawable, GLAMOR_ACCESS_RW)) {
|
fbValidateGC(gc, changes, drawable);
|
||||||
fbValidateGC(gc, changes, drawable);
|
glamor_finish_access(&gc->stipple->drawable, GLAMOR_ACCESS_RW);
|
||||||
glamor_finish_access(&gc->stipple->drawable, GLAMOR_ACCESS_RW);
|
}
|
||||||
}
|
}
|
||||||
} else {
|
else {
|
||||||
fbValidateGC(gc, changes, drawable);
|
fbValidateGC(gc, changes, drawable);
|
||||||
}
|
}
|
||||||
|
|
||||||
gc->ops = &glamor_gc_ops;
|
gc->ops = &glamor_gc_ops;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GCFuncs glamor_gc_funcs = {
|
static GCFuncs glamor_gc_funcs = {
|
||||||
glamor_validate_gc,
|
glamor_validate_gc,
|
||||||
miChangeGC,
|
miChangeGC,
|
||||||
miCopyGC,
|
miCopyGC,
|
||||||
miDestroyGC,
|
miDestroyGC,
|
||||||
miChangeClip,
|
miChangeClip,
|
||||||
miDestroyClip,
|
miDestroyClip,
|
||||||
miCopyClip
|
miCopyClip
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -547,66 +517,69 @@ static GCFuncs glamor_gc_funcs = {
|
||||||
int
|
int
|
||||||
glamor_create_gc(GCPtr gc)
|
glamor_create_gc(GCPtr gc)
|
||||||
{
|
{
|
||||||
if (!fbCreateGC(gc))
|
if (!fbCreateGC(gc))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
gc->funcs = &glamor_gc_funcs;
|
gc->funcs = &glamor_gc_funcs;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegionPtr
|
RegionPtr
|
||||||
glamor_bitmap_to_region(PixmapPtr pixmap)
|
glamor_bitmap_to_region(PixmapPtr pixmap)
|
||||||
{
|
{
|
||||||
RegionPtr ret;
|
RegionPtr ret;
|
||||||
glamor_fallback("pixmap %p \n", pixmap);
|
|
||||||
if (!glamor_prepare_access(&pixmap->drawable, GLAMOR_ACCESS_RO))
|
glamor_fallback("pixmap %p \n", pixmap);
|
||||||
return NULL;
|
if (!glamor_prepare_access(&pixmap->drawable, GLAMOR_ACCESS_RO))
|
||||||
ret = fbPixmapToRegion(pixmap);
|
return NULL;
|
||||||
glamor_finish_access(&pixmap->drawable, GLAMOR_ACCESS_RO);
|
ret = fbPixmapToRegion(pixmap);
|
||||||
return ret;
|
glamor_finish_access(&pixmap->drawable, GLAMOR_ACCESS_RO);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Borrow from cairo. */
|
/* Borrow from cairo. */
|
||||||
Bool
|
Bool
|
||||||
glamor_gl_has_extension(const char *extension)
|
glamor_gl_has_extension(const char *extension)
|
||||||
{
|
{
|
||||||
const char *pext;
|
const char *pext;
|
||||||
int ext_len;
|
int ext_len;
|
||||||
ext_len = strlen(extension);
|
|
||||||
|
|
||||||
pext = (const char*)glGetString(GL_EXTENSIONS);
|
ext_len = strlen(extension);
|
||||||
|
|
||||||
if (pext == NULL || extension == NULL)
|
pext = (const char *) glGetString(GL_EXTENSIONS);
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
while ((pext = strstr(pext, extension)) != NULL) {
|
if (pext == NULL || extension == NULL)
|
||||||
if (pext[ext_len] == ' ' || pext[ext_len] == '\0')
|
return FALSE;
|
||||||
return TRUE;
|
|
||||||
pext += ext_len;
|
while ((pext = strstr(pext, extension)) != NULL) {
|
||||||
}
|
if (pext[ext_len] == ' ' || pext[ext_len] == '\0')
|
||||||
return FALSE;
|
return TRUE;
|
||||||
|
pext += ext_len;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
glamor_gl_get_version(void)
|
glamor_gl_get_version(void)
|
||||||
{
|
{
|
||||||
int major, minor;
|
int major, minor;
|
||||||
const char *version = (const char *) glGetString(GL_VERSION);
|
const char *version = (const char *) glGetString(GL_VERSION);
|
||||||
const char *dot = version == NULL ? NULL : strchr(version, '.');
|
const char *dot = version == NULL ? NULL : strchr(version, '.');
|
||||||
const char *major_start = dot;
|
const char *major_start = dot;
|
||||||
|
|
||||||
/* Sanity check */
|
/* Sanity check */
|
||||||
if (dot == NULL || dot == version || *(dot + 1) == '\0') {
|
if (dot == NULL || dot == version || *(dot + 1) == '\0') {
|
||||||
major = 0;
|
major = 0;
|
||||||
minor = 0;
|
minor = 0;
|
||||||
} else {
|
}
|
||||||
/* Find the start of the major version in the string */
|
else {
|
||||||
while (major_start > version && *major_start != ' ')
|
/* Find the start of the major version in the string */
|
||||||
--major_start;
|
while (major_start > version && *major_start != ' ')
|
||||||
major = strtol(major_start, NULL, 10);
|
--major_start;
|
||||||
minor = strtol(dot + 1, NULL, 10);
|
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__
|
#ifndef __GLAMOR_DEBUG_H__
|
||||||
#define __GLAMOR_DEBUG_H__
|
#define __GLAMOR_DEBUG_H__
|
||||||
|
|
||||||
|
|
||||||
#define GLAMOR_DELAYED_STRING_MAX 64
|
#define GLAMOR_DELAYED_STRING_MAX 64
|
||||||
|
|
||||||
#define GLAMOR_DEBUG_NONE 0
|
#define GLAMOR_DEBUG_NONE 0
|
||||||
|
@ -51,9 +50,6 @@ AbortServer(void)
|
||||||
exit(1); \
|
exit(1); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define __debug_output_message(_format_, _prefix_, ...) \
|
#define __debug_output_message(_format_, _prefix_, ...) \
|
||||||
LogMessageVerb(X_NONE, 0, \
|
LogMessageVerb(X_NONE, 0, \
|
||||||
"%32s:\t" _format_ , \
|
"%32s:\t" _format_ , \
|
||||||
|
@ -69,7 +65,6 @@ AbortServer(void)
|
||||||
##__VA_ARGS__); \
|
##__VA_ARGS__); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
|
||||||
#define glamor_fallback(_format_,...) \
|
#define glamor_fallback(_format_,...) \
|
||||||
do { \
|
do { \
|
||||||
if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) \
|
if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) \
|
||||||
|
@ -77,8 +72,6 @@ AbortServer(void)
|
||||||
"Glamor fallback", \
|
"Glamor fallback", \
|
||||||
##__VA_ARGS__);} while(0)
|
##__VA_ARGS__);} while(0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define glamor_delayed_fallback(_screen_, _format_,...) \
|
#define glamor_delayed_fallback(_screen_, _format_,...) \
|
||||||
do { \
|
do { \
|
||||||
if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) { \
|
if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) { \
|
||||||
|
@ -90,7 +83,6 @@ AbortServer(void)
|
||||||
"glamor delayed fallback: \t%s " _format_ , \
|
"glamor delayed fallback: \t%s " _format_ , \
|
||||||
__FUNCTION__, ##__VA_ARGS__); } } while(0)
|
__FUNCTION__, ##__VA_ARGS__); } } while(0)
|
||||||
|
|
||||||
|
|
||||||
#define glamor_clear_delayed_fallbacks(_screen_) \
|
#define glamor_clear_delayed_fallbacks(_screen_) \
|
||||||
do { \
|
do { \
|
||||||
if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) { \
|
if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) { \
|
||||||
|
@ -112,5 +104,4 @@ AbortServer(void)
|
||||||
#define DEBUGRegionPrint(x) do {} while (0)
|
#define DEBUGRegionPrint(x) do {} while (0)
|
||||||
//#define DEBUGRegionPrint RegionPrint
|
//#define DEBUGRegionPrint RegionPrint
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#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
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
* copy of this software and associated documentation files (the "Software"),
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
@ -16,44 +16,49 @@
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
* 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,
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
* SOFTWARE.
|
* IN THE SOFTWARE.
|
||||||
*
|
|
||||||
* Authors:
|
|
||||||
* Chris Wilson <chris@chris-wilson.co.uk>
|
|
||||||
*
|
|
||||||
* Copied from sna
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _GLAMOR_COMPILER_H_
|
/** @file glamor_egl_stubs.c
|
||||||
#define _GLAMOR_COMPILER_H_
|
*
|
||||||
|
* Stubbed out glamor_egl.c functions for servers other than Xorg.
|
||||||
|
*/
|
||||||
|
|
||||||
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
|
#include "glamor_priv.h"
|
||||||
#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
|
|
||||||
|
|
||||||
#ifdef HAVE_VALGRIND
|
void
|
||||||
#define VG(x) x
|
glamor_egl_screen_init(ScreenPtr screen)
|
||||||
#else
|
{
|
||||||
#define VG(x)
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#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>
|
* Zhigang Gong <zhigang.gong@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#include "dix-config.h"
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <xorg-server.h>
|
#include <xorg-server.h>
|
||||||
#define GLAMOR_FOR_XORG
|
#define GLAMOR_FOR_XORG
|
||||||
|
@ -37,16 +35,16 @@
|
||||||
#include "glamor.h"
|
#include "glamor.h"
|
||||||
|
|
||||||
static XF86ModuleVersionInfo VersRec = {
|
static XF86ModuleVersionInfo VersRec = {
|
||||||
GLAMOR_EGL_MODULE_NAME,
|
GLAMOR_EGL_MODULE_NAME,
|
||||||
MODULEVENDORSTRING,
|
MODULEVENDORSTRING,
|
||||||
MODINFOSTRING1,
|
MODINFOSTRING1,
|
||||||
MODINFOSTRING2,
|
MODINFOSTRING2,
|
||||||
XORG_VERSION_CURRENT,
|
XORG_VERSION_CURRENT,
|
||||||
PACKAGE_VERSION_MAJOR, PACKAGE_VERSION_MINOR, PACKAGE_VERSION_PATCHLEVEL,
|
PACKAGE_VERSION_MAJOR, PACKAGE_VERSION_MINOR, PACKAGE_VERSION_PATCHLEVEL,
|
||||||
ABI_CLASS_ANSIC, /* Only need the ansic layer */
|
ABI_CLASS_ANSIC, /* Only need the ansic layer */
|
||||||
ABI_ANSIC_VERSION,
|
ABI_ANSIC_VERSION,
|
||||||
MOD_CLASS_NONE,
|
MOD_CLASS_NONE,
|
||||||
{0, 0, 0, 0} /* signature, to be patched into the file by a tool */
|
{0, 0, 0, 0} /* signature, to be patched into the file by a tool */
|
||||||
};
|
};
|
||||||
|
|
||||||
_X_EXPORT XF86ModuleData glamoreglModuleData = { &VersRec, NULL, NULL };
|
_X_EXPORT XF86ModuleData glamoreglModuleData = { &VersRec, NULL, NULL };
|
||||||
|
|
|
@ -44,547 +44,552 @@
|
||||||
&pos->member != (head); \
|
&pos->member != (head); \
|
||||||
pos = __container_of(pos->member.prev, pos, member))
|
pos = __container_of(pos->member.prev, pos, member))
|
||||||
|
|
||||||
|
|
||||||
#define xorg_list_for_each_entry_safe_reverse(pos, tmp, head, member) \
|
#define xorg_list_for_each_entry_safe_reverse(pos, tmp, head, member) \
|
||||||
for (pos = __container_of((head)->prev, pos, member), \
|
for (pos = __container_of((head)->prev, pos, member), \
|
||||||
tmp = __container_of(pos->member.prev, pos, member); \
|
tmp = __container_of(pos->member.prev, pos, member); \
|
||||||
&pos->member != (head); \
|
&pos->member != (head); \
|
||||||
pos = tmp, tmp = __container_of(pos->member.prev, tmp, member))
|
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);
|
int order = __fls(size / 32);
|
||||||
if (order >= CACHE_BUCKET_WCOUNT)
|
|
||||||
order = CACHE_BUCKET_WCOUNT - 1;
|
if (order >= CACHE_BUCKET_WCOUNT)
|
||||||
return order;
|
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);
|
int order = __fls(size / 32);
|
||||||
if (order >= CACHE_BUCKET_HCOUNT)
|
|
||||||
order = CACHE_BUCKET_HCOUNT - 1;
|
if (order >= CACHE_BUCKET_HCOUNT)
|
||||||
return order;
|
order = CACHE_BUCKET_HCOUNT - 1;
|
||||||
|
return order;
|
||||||
}
|
}
|
||||||
|
|
||||||
static glamor_pixmap_fbo *
|
static glamor_pixmap_fbo *
|
||||||
glamor_pixmap_fbo_cache_get(glamor_screen_private *glamor_priv,
|
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;
|
struct xorg_list *cache;
|
||||||
glamor_pixmap_fbo *fbo_entry, *ret_fbo = NULL;
|
glamor_pixmap_fbo *fbo_entry, *ret_fbo = NULL;
|
||||||
int n_format;
|
int n_format;
|
||||||
|
|
||||||
#ifdef NO_FBO_CACHE
|
#ifdef NO_FBO_CACHE
|
||||||
return NULL;
|
return NULL;
|
||||||
#else
|
#else
|
||||||
n_format = cache_format(format);
|
n_format = cache_format(format);
|
||||||
if (n_format == -1)
|
if (n_format == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
cache = &glamor_priv->fbo_cache[n_format]
|
cache = &glamor_priv->fbo_cache[n_format]
|
||||||
[cache_wbucket(w)]
|
[cache_wbucket(w)]
|
||||||
[cache_hbucket(h)];
|
[cache_hbucket(h)];
|
||||||
if (!(flag & GLAMOR_CACHE_EXACT_SIZE)) {
|
if (!(flag & GLAMOR_CACHE_EXACT_SIZE)) {
|
||||||
xorg_list_for_each_entry(fbo_entry, cache, list) {
|
xorg_list_for_each_entry(fbo_entry, cache, list) {
|
||||||
if (fbo_entry->width >= w && fbo_entry->height >= h) {
|
if (fbo_entry->width >= w && fbo_entry->height >= h) {
|
||||||
|
|
||||||
DEBUGF("Request w %d h %d format %x \n", w, h, format);
|
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",
|
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, fbo_entry->width, fbo_entry->height,
|
||||||
fbo_entry->fb, fbo_entry->tex);
|
fbo_entry->fb, fbo_entry->tex);
|
||||||
xorg_list_del(&fbo_entry->list);
|
xorg_list_del(&fbo_entry->list);
|
||||||
ret_fbo = fbo_entry;
|
ret_fbo = fbo_entry;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
xorg_list_for_each_entry(fbo_entry, cache, list) {
|
xorg_list_for_each_entry(fbo_entry, cache, list) {
|
||||||
if (fbo_entry->width == w && fbo_entry->height == h) {
|
if (fbo_entry->width == w && fbo_entry->height == h) {
|
||||||
|
|
||||||
DEBUGF("Request w %d h %d format %x \n", w, h, format);
|
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",
|
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, fbo_entry->width, fbo_entry->height,
|
||||||
fbo_entry->fb, fbo_entry->tex, fbo_entry->format);
|
fbo_entry->fb, fbo_entry->tex, fbo_entry->format);
|
||||||
assert(format == fbo_entry->format);
|
assert(format == fbo_entry->format);
|
||||||
xorg_list_del(&fbo_entry->list);
|
xorg_list_del(&fbo_entry->list);
|
||||||
ret_fbo = fbo_entry;
|
ret_fbo = fbo_entry;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret_fbo)
|
if (ret_fbo)
|
||||||
glamor_priv->fbo_cache_watermark -= ret_fbo->width * ret_fbo->height;
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_purge_fbo(glamor_pixmap_fbo *fbo)
|
glamor_purge_fbo(glamor_pixmap_fbo *fbo)
|
||||||
{
|
{
|
||||||
glamor_gl_dispatch *dispatch = glamor_get_dispatch(fbo->glamor_priv);
|
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);
|
|
||||||
|
|
||||||
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
|
static void
|
||||||
glamor_pixmap_fbo_cache_put(glamor_pixmap_fbo *fbo)
|
glamor_pixmap_fbo_cache_put(glamor_pixmap_fbo *fbo)
|
||||||
{
|
{
|
||||||
struct xorg_list *cache;
|
struct xorg_list *cache;
|
||||||
int n_format;
|
int n_format;
|
||||||
|
|
||||||
#ifdef NO_FBO_CACHE
|
#ifdef NO_FBO_CACHE
|
||||||
glamor_purge_fbo(fbo);
|
glamor_purge_fbo(fbo);
|
||||||
return;
|
return;
|
||||||
#else
|
#else
|
||||||
n_format = cache_format(fbo->format);
|
n_format = cache_format(fbo->format);
|
||||||
|
|
||||||
if (fbo->fb == 0 || n_format == -1
|
if (fbo->fb == 0 || n_format == -1
|
||||||
|| fbo->glamor_priv->fbo_cache_watermark >= FBO_CACHE_THRESHOLD) {
|
|| fbo->glamor_priv->fbo_cache_watermark >= FBO_CACHE_THRESHOLD) {
|
||||||
fbo->glamor_priv->tick += GLAMOR_CACHE_EXPIRE_MAX;
|
fbo->glamor_priv->tick += GLAMOR_CACHE_EXPIRE_MAX;
|
||||||
glamor_fbo_expire(fbo->glamor_priv);
|
glamor_fbo_expire(fbo->glamor_priv);
|
||||||
glamor_purge_fbo(fbo);
|
glamor_purge_fbo(fbo);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cache = &fbo->glamor_priv->fbo_cache[n_format]
|
cache = &fbo->glamor_priv->fbo_cache[n_format]
|
||||||
[cache_wbucket(fbo->width)]
|
[cache_wbucket(fbo->width)]
|
||||||
[cache_hbucket(fbo->height)];
|
[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,
|
DEBUGF
|
||||||
fbo->width, fbo->height, fbo->format, fbo->fb, fbo->tex);
|
("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;
|
fbo->glamor_priv->fbo_cache_watermark += fbo->width * fbo->height;
|
||||||
xorg_list_add(&fbo->list, cache);
|
xorg_list_add(&fbo->list, cache);
|
||||||
fbo->expire = fbo->glamor_priv->tick + GLAMOR_CACHE_EXPIRE_MAX;
|
fbo->expire = fbo->glamor_priv->tick + GLAMOR_CACHE_EXPIRE_MAX;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
glamor_pixmap_ensure_fb(glamor_pixmap_fbo *fbo)
|
glamor_pixmap_ensure_fb(glamor_pixmap_fbo *fbo)
|
||||||
{
|
{
|
||||||
glamor_gl_dispatch *dispatch;
|
glamor_gl_dispatch *dispatch;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
dispatch = glamor_get_dispatch(fbo->glamor_priv);
|
dispatch = glamor_get_dispatch(fbo->glamor_priv);
|
||||||
|
|
||||||
if (fbo->fb == 0)
|
if (fbo->fb == 0)
|
||||||
dispatch->glGenFramebuffers(1, &fbo->fb);
|
dispatch->glGenFramebuffers(1, &fbo->fb);
|
||||||
assert(fbo->tex != 0);
|
assert(fbo->tex != 0);
|
||||||
dispatch->glBindFramebuffer(GL_FRAMEBUFFER, fbo->fb);
|
dispatch->glBindFramebuffer(GL_FRAMEBUFFER, fbo->fb);
|
||||||
dispatch->glFramebufferTexture2D(GL_FRAMEBUFFER,
|
dispatch->glFramebufferTexture2D(GL_FRAMEBUFFER,
|
||||||
GL_COLOR_ATTACHMENT0,
|
GL_COLOR_ATTACHMENT0,
|
||||||
GL_TEXTURE_2D, fbo->tex,
|
GL_TEXTURE_2D, fbo->tex, 0);
|
||||||
0);
|
status = dispatch->glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||||
status = dispatch->glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
if (status != GL_FRAMEBUFFER_COMPLETE) {
|
||||||
if (status != GL_FRAMEBUFFER_COMPLETE) {
|
const char *str;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
FatalError("destination is framebuffer incomplete: %s [%x]\n",
|
switch (status) {
|
||||||
str, status);
|
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
|
||||||
}
|
str = "incomplete attachment";
|
||||||
glamor_put_dispatch(fbo->glamor_priv);
|
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_pixmap_fbo *
|
||||||
glamor_create_fbo_from_tex(glamor_screen_private *glamor_priv,
|
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));
|
fbo = calloc(1, sizeof(*fbo));
|
||||||
if (fbo == NULL)
|
if (fbo == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
xorg_list_init(&fbo->list);
|
xorg_list_init(&fbo->list);
|
||||||
|
|
||||||
fbo->tex = tex;
|
fbo->tex = tex;
|
||||||
fbo->width = w;
|
fbo->width = w;
|
||||||
fbo->height = h;
|
fbo->height = h;
|
||||||
fbo->format = format;
|
fbo->format = format;
|
||||||
fbo->glamor_priv = glamor_priv;
|
fbo->glamor_priv = glamor_priv;
|
||||||
|
|
||||||
if (flag == GLAMOR_CREATE_PIXMAP_MAP) {
|
if (flag == GLAMOR_CREATE_PIXMAP_MAP) {
|
||||||
glamor_gl_dispatch *dispatch;
|
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_FBO_NO_FBO)
|
dispatch = glamor_get_dispatch(glamor_priv);
|
||||||
glamor_pixmap_ensure_fb(fbo);
|
dispatch->glGenBuffers(1, &fbo->pbo);
|
||||||
|
glamor_put_dispatch(glamor_priv);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
done:
|
if (flag != GLAMOR_CREATE_FBO_NO_FBO)
|
||||||
return fbo;
|
glamor_pixmap_ensure_fb(fbo);
|
||||||
|
|
||||||
|
done:
|
||||||
|
return fbo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_fbo_expire(glamor_screen_private *glamor_priv)
|
glamor_fbo_expire(glamor_screen_private *glamor_priv)
|
||||||
{
|
{
|
||||||
struct xorg_list *cache;
|
struct xorg_list *cache;
|
||||||
glamor_pixmap_fbo *fbo_entry, *tmp;
|
glamor_pixmap_fbo *fbo_entry, *tmp;
|
||||||
int i,j,k;
|
int i, j, k;
|
||||||
|
|
||||||
for(i = 0; i < CACHE_FORMAT_COUNT; i++)
|
for (i = 0; i < CACHE_FORMAT_COUNT; i++)
|
||||||
for(j = 0; j < CACHE_BUCKET_WCOUNT; j++)
|
for (j = 0; j < CACHE_BUCKET_WCOUNT; j++)
|
||||||
for(k = 0; k < CACHE_BUCKET_HCOUNT; k++) {
|
for (k = 0; k < CACHE_BUCKET_HCOUNT; k++) {
|
||||||
cache = &glamor_priv->fbo_cache[i][j][k];
|
cache = &glamor_priv->fbo_cache[i][j][k];
|
||||||
xorg_list_for_each_entry_safe_reverse(fbo_entry, tmp, cache, list) {
|
xorg_list_for_each_entry_safe_reverse(fbo_entry, tmp, cache,
|
||||||
if (GLAMOR_TICK_AFTER(fbo_entry->expire, glamor_priv->tick)) {
|
list) {
|
||||||
break;
|
if (GLAMOR_TICK_AFTER(fbo_entry->expire, glamor_priv->tick)) {
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
glamor_priv->fbo_cache_watermark -= fbo_entry->width * fbo_entry->height;
|
glamor_priv->fbo_cache_watermark -=
|
||||||
xorg_list_del(&fbo_entry->list);
|
fbo_entry->width * fbo_entry->height;
|
||||||
DEBUGF("cache %p fbo %p expired %d current %d \n", cache, fbo_entry,
|
xorg_list_del(&fbo_entry->list);
|
||||||
fbo_entry->expire, glamor_priv->tick);
|
DEBUGF("cache %p fbo %p expired %d current %d \n", cache,
|
||||||
glamor_purge_fbo(fbo_entry);
|
fbo_entry, fbo_entry->expire, glamor_priv->tick);
|
||||||
}
|
glamor_purge_fbo(fbo_entry);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_init_pixmap_fbo(ScreenPtr screen)
|
glamor_init_pixmap_fbo(ScreenPtr screen)
|
||||||
{
|
{
|
||||||
glamor_screen_private *glamor_priv;
|
glamor_screen_private *glamor_priv;
|
||||||
int i,j,k;
|
int i, j, k;
|
||||||
|
|
||||||
glamor_priv = glamor_get_screen_private(screen);
|
glamor_priv = glamor_get_screen_private(screen);
|
||||||
for(i = 0; i < CACHE_FORMAT_COUNT; i++)
|
for (i = 0; i < CACHE_FORMAT_COUNT; i++)
|
||||||
for(j = 0; j < CACHE_BUCKET_WCOUNT; j++)
|
for (j = 0; j < CACHE_BUCKET_WCOUNT; j++)
|
||||||
for(k = 0; k < CACHE_BUCKET_HCOUNT; k++)
|
for (k = 0; k < CACHE_BUCKET_HCOUNT; k++) {
|
||||||
{
|
xorg_list_init(&glamor_priv->fbo_cache[i][j][k]);
|
||||||
xorg_list_init(&glamor_priv->fbo_cache[i][j][k]);
|
}
|
||||||
}
|
glamor_priv->fbo_cache_watermark = 0;
|
||||||
glamor_priv->fbo_cache_watermark = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_fini_pixmap_fbo(ScreenPtr screen)
|
glamor_fini_pixmap_fbo(ScreenPtr screen)
|
||||||
{
|
{
|
||||||
struct xorg_list *cache;
|
struct xorg_list *cache;
|
||||||
glamor_screen_private *glamor_priv;
|
glamor_screen_private *glamor_priv;
|
||||||
glamor_pixmap_fbo *fbo_entry, *tmp;
|
glamor_pixmap_fbo *fbo_entry, *tmp;
|
||||||
int i,j,k;
|
int i, j, k;
|
||||||
|
|
||||||
glamor_priv = glamor_get_screen_private(screen);
|
glamor_priv = glamor_get_screen_private(screen);
|
||||||
for(i = 0; i < CACHE_FORMAT_COUNT; i++)
|
for (i = 0; i < CACHE_FORMAT_COUNT; i++)
|
||||||
for(j = 0; j < CACHE_BUCKET_WCOUNT; j++)
|
for (j = 0; j < CACHE_BUCKET_WCOUNT; j++)
|
||||||
for(k = 0; k < CACHE_BUCKET_HCOUNT; k++)
|
for (k = 0; k < CACHE_BUCKET_HCOUNT; k++) {
|
||||||
{
|
cache = &glamor_priv->fbo_cache[i][j][k];
|
||||||
cache = &glamor_priv->fbo_cache[i][j][k];
|
xorg_list_for_each_entry_safe_reverse(fbo_entry, tmp, cache,
|
||||||
xorg_list_for_each_entry_safe_reverse(fbo_entry, tmp, cache, list) {
|
list) {
|
||||||
xorg_list_del(&fbo_entry->list);
|
xorg_list_del(&fbo_entry->list);
|
||||||
glamor_purge_fbo(fbo_entry);
|
glamor_purge_fbo(fbo_entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_destroy_fbo(glamor_pixmap_fbo *fbo)
|
glamor_destroy_fbo(glamor_pixmap_fbo *fbo)
|
||||||
{
|
{
|
||||||
xorg_list_del(&fbo->list);
|
xorg_list_del(&fbo->list);
|
||||||
glamor_pixmap_fbo_cache_put(fbo);
|
glamor_pixmap_fbo_cache_put(fbo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_glamor_create_tex(glamor_screen_private *glamor_priv,
|
_glamor_create_tex(glamor_screen_private *glamor_priv,
|
||||||
int w, int h, GLenum format)
|
int w, int h, GLenum format)
|
||||||
{
|
{
|
||||||
glamor_gl_dispatch *dispatch;
|
glamor_gl_dispatch *dispatch;
|
||||||
unsigned int tex = 0;
|
unsigned int tex = 0;
|
||||||
|
|
||||||
/* With dri3, we want to allocate ARGB8888 pixmaps only.
|
/* With dri3, we want to allocate ARGB8888 pixmaps only.
|
||||||
* Depending on the implementation, GL_RGBA might not
|
* Depending on the implementation, GL_RGBA might not
|
||||||
* give us ARGB8888. We ask glamor_egl to use get
|
* give us ARGB8888. We ask glamor_egl to use get
|
||||||
* an ARGB8888 based texture for us. */
|
* an ARGB8888 based texture for us. */
|
||||||
if (glamor_priv->dri3_enabled && format == GL_RGBA)
|
if (glamor_priv->dri3_enabled && format == GL_RGBA) {
|
||||||
{
|
tex = glamor_egl_create_argb8888_based_texture(glamor_priv->screen,
|
||||||
tex = glamor_egl_create_argb8888_based_texture(glamor_priv->screen,
|
w, h);
|
||||||
w, h);
|
}
|
||||||
}
|
if (!tex) {
|
||||||
if (!tex)
|
dispatch = glamor_get_dispatch(glamor_priv);
|
||||||
{
|
dispatch->glGenTextures(1, &tex);
|
||||||
dispatch = glamor_get_dispatch(glamor_priv);
|
dispatch->glBindTexture(GL_TEXTURE_2D, tex);
|
||||||
dispatch->glGenTextures(1, &tex);
|
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
||||||
dispatch->glBindTexture(GL_TEXTURE_2D, tex);
|
GL_NEAREST);
|
||||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
|
||||||
GL_NEAREST);
|
GL_NEAREST);
|
||||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
|
dispatch->glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0,
|
||||||
GL_NEAREST);
|
format, GL_UNSIGNED_BYTE, NULL);
|
||||||
dispatch->glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0,
|
glamor_put_dispatch(glamor_priv);
|
||||||
format, GL_UNSIGNED_BYTE, NULL);
|
}
|
||||||
glamor_put_dispatch(glamor_priv);
|
return tex;
|
||||||
}
|
|
||||||
return tex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glamor_pixmap_fbo *
|
glamor_pixmap_fbo *
|
||||||
glamor_create_fbo(glamor_screen_private *glamor_priv,
|
glamor_create_fbo(glamor_screen_private *glamor_priv,
|
||||||
int w, int h,
|
int w, int h, GLenum format, int flag)
|
||||||
GLenum format,
|
|
||||||
int flag)
|
|
||||||
{
|
{
|
||||||
glamor_pixmap_fbo *fbo;
|
glamor_pixmap_fbo *fbo;
|
||||||
GLint tex = 0;
|
GLint tex = 0;
|
||||||
int cache_flag;
|
int cache_flag;
|
||||||
|
|
||||||
if (!glamor_check_fbo_size(glamor_priv, w, h))
|
if (!glamor_check_fbo_size(glamor_priv, w, h))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (flag == GLAMOR_CREATE_FBO_NO_FBO)
|
if (flag == GLAMOR_CREATE_FBO_NO_FBO)
|
||||||
goto new_fbo;
|
goto new_fbo;
|
||||||
|
|
||||||
if (flag == GLAMOR_CREATE_PIXMAP_MAP)
|
if (flag == GLAMOR_CREATE_PIXMAP_MAP)
|
||||||
goto no_tex;
|
goto no_tex;
|
||||||
|
|
||||||
if (flag == GLAMOR_CREATE_PIXMAP_FIXUP)
|
if (flag == GLAMOR_CREATE_PIXMAP_FIXUP)
|
||||||
cache_flag = GLAMOR_CACHE_EXACT_SIZE;
|
cache_flag = GLAMOR_CACHE_EXACT_SIZE;
|
||||||
else
|
else
|
||||||
cache_flag = 0;
|
cache_flag = 0;
|
||||||
|
|
||||||
fbo = glamor_pixmap_fbo_cache_get(glamor_priv, w, h,
|
fbo = glamor_pixmap_fbo_cache_get(glamor_priv, w, h, format, cache_flag);
|
||||||
format, cache_flag);
|
if (fbo)
|
||||||
if (fbo)
|
return fbo;
|
||||||
return fbo;
|
new_fbo:
|
||||||
new_fbo:
|
tex = _glamor_create_tex(glamor_priv, w, h, format);
|
||||||
tex = _glamor_create_tex(glamor_priv, w, h, format);
|
no_tex:
|
||||||
no_tex:
|
fbo = glamor_create_fbo_from_tex(glamor_priv, w, h, format, tex, flag);
|
||||||
fbo = glamor_create_fbo_from_tex(glamor_priv, w, h, format, tex, flag);
|
|
||||||
|
|
||||||
return fbo;
|
return fbo;
|
||||||
}
|
}
|
||||||
|
|
||||||
static glamor_pixmap_fbo *
|
static glamor_pixmap_fbo *
|
||||||
_glamor_create_fbo_array(glamor_screen_private *glamor_priv,
|
_glamor_create_fbo_array(glamor_screen_private *glamor_priv,
|
||||||
int w, int h, GLenum format, int flag,
|
int w, int h, GLenum format, int flag,
|
||||||
int block_w, int block_h,
|
int block_w, int block_h,
|
||||||
glamor_pixmap_private *pixmap_priv,
|
glamor_pixmap_private *pixmap_priv, int has_fbo)
|
||||||
int has_fbo)
|
|
||||||
{
|
{
|
||||||
int block_wcnt;
|
int block_wcnt;
|
||||||
int block_hcnt;
|
int block_hcnt;
|
||||||
glamor_pixmap_fbo **fbo_array;
|
glamor_pixmap_fbo **fbo_array;
|
||||||
BoxPtr box_array;
|
BoxPtr box_array;
|
||||||
int i,j;
|
int i, j;
|
||||||
glamor_pixmap_private_large_t *priv;
|
glamor_pixmap_private_large_t *priv;
|
||||||
|
|
||||||
priv = &pixmap_priv->large;
|
priv = &pixmap_priv->large;
|
||||||
|
|
||||||
block_wcnt = (w + block_w - 1) / block_w;
|
block_wcnt = (w + block_w - 1) / block_w;
|
||||||
block_hcnt = (h + block_h - 1) / block_h;
|
block_hcnt = (h + block_h - 1) / block_h;
|
||||||
|
|
||||||
box_array = calloc(block_wcnt * block_hcnt, sizeof(box_array[0]));
|
box_array = calloc(block_wcnt * block_hcnt, sizeof(box_array[0]));
|
||||||
if (box_array == NULL)
|
if (box_array == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
fbo_array = calloc(block_wcnt * block_hcnt, sizeof(glamor_pixmap_fbo*));
|
fbo_array = calloc(block_wcnt * block_hcnt, sizeof(glamor_pixmap_fbo *));
|
||||||
if (fbo_array == NULL) {
|
if (fbo_array == NULL) {
|
||||||
free(box_array);
|
free(box_array);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
for(i = 0; i < block_hcnt; i++)
|
for (i = 0; i < block_hcnt; i++) {
|
||||||
{
|
int block_y1, block_y2;
|
||||||
int block_y1, block_y2;
|
int fbo_w, fbo_h;
|
||||||
int fbo_w, fbo_h;
|
|
||||||
|
|
||||||
block_y1 = i * block_h;
|
block_y1 = i * block_h;
|
||||||
block_y2 = (block_y1 + block_h) > h ? h : (block_y1 + block_h);
|
block_y2 = (block_y1 + block_h) > h ? h : (block_y1 + block_h);
|
||||||
fbo_h = block_y2 - block_y1;
|
fbo_h = block_y2 - block_y1;
|
||||||
|
|
||||||
for (j = 0; j < block_wcnt; j++)
|
for (j = 0; j < block_wcnt; j++) {
|
||||||
{
|
box_array[i * block_wcnt + j].x1 = j * block_w;
|
||||||
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].y1 = block_y1;
|
box_array[i * block_wcnt + j].x2 =
|
||||||
box_array[i * block_wcnt + j].x2 = (j + 1) * block_w > w ? w : (j + 1) * block_w;
|
(j + 1) * block_w > w ? w : (j + 1) * block_w;
|
||||||
box_array[i * block_wcnt + j].y2 = block_y2;
|
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;
|
fbo_w =
|
||||||
if (!has_fbo)
|
box_array[i * block_wcnt + j].x2 - box_array[i * block_wcnt +
|
||||||
fbo_array[i * block_wcnt + j] = glamor_create_fbo(glamor_priv,
|
j].x1;
|
||||||
fbo_w, fbo_h, format,
|
if (!has_fbo)
|
||||||
GLAMOR_CREATE_PIXMAP_FIXUP);
|
fbo_array[i * block_wcnt + j] = glamor_create_fbo(glamor_priv,
|
||||||
else
|
fbo_w, fbo_h,
|
||||||
fbo_array[i * block_wcnt + j] = priv->base.fbo;
|
format,
|
||||||
if (fbo_array[i * block_wcnt + j] == NULL)
|
GLAMOR_CREATE_PIXMAP_FIXUP);
|
||||||
goto cleanup;
|
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 = box_array[0];
|
||||||
priv->box_array = box_array;
|
priv->box_array = box_array;
|
||||||
priv->fbo_array = fbo_array;
|
priv->fbo_array = fbo_array;
|
||||||
priv->block_wcnt = block_wcnt;
|
priv->block_wcnt = block_wcnt;
|
||||||
priv->block_hcnt = block_hcnt;
|
priv->block_hcnt = block_hcnt;
|
||||||
return fbo_array[0];
|
return fbo_array[0];
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
for(i = 0; i < block_wcnt * block_hcnt; i++)
|
for (i = 0; i < block_wcnt * block_hcnt; i++)
|
||||||
if ((fbo_array)[i])
|
if ((fbo_array)[i])
|
||||||
glamor_destroy_fbo((fbo_array)[i]);
|
glamor_destroy_fbo((fbo_array)[i]);
|
||||||
free(box_array);
|
free(box_array);
|
||||||
free(fbo_array);
|
free(fbo_array);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Create a fbo array to cover the w*h region, by using block_w*block_h
|
/* Create a fbo array to cover the w*h region, by using block_w*block_h
|
||||||
* block.*/
|
* block.*/
|
||||||
glamor_pixmap_fbo *
|
glamor_pixmap_fbo *
|
||||||
glamor_create_fbo_array(glamor_screen_private *glamor_priv,
|
glamor_create_fbo_array(glamor_screen_private *glamor_priv,
|
||||||
int w, int h, GLenum format, int flag,
|
int w, int h, GLenum format, int flag,
|
||||||
int block_w, int block_h,
|
int block_w, int block_h,
|
||||||
glamor_pixmap_private *pixmap_priv)
|
glamor_pixmap_private *pixmap_priv)
|
||||||
{
|
{
|
||||||
pixmap_priv->large.block_w = block_w;
|
pixmap_priv->large.block_w = block_w;
|
||||||
pixmap_priv->large.block_h = block_h;
|
pixmap_priv->large.block_h = block_h;
|
||||||
return _glamor_create_fbo_array(glamor_priv, w, h, format, flag,
|
return _glamor_create_fbo_array(glamor_priv, w, h, format, flag,
|
||||||
block_w, block_h, pixmap_priv, 0);
|
block_w, block_h, pixmap_priv, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
glamor_pixmap_fbo *
|
glamor_pixmap_fbo *
|
||||||
glamor_pixmap_detach_fbo(glamor_pixmap_private *pixmap_priv)
|
glamor_pixmap_detach_fbo(glamor_pixmap_private *pixmap_priv)
|
||||||
{
|
{
|
||||||
glamor_pixmap_fbo *fbo;
|
glamor_pixmap_fbo *fbo;
|
||||||
|
|
||||||
if (pixmap_priv == NULL)
|
if (pixmap_priv == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
fbo = pixmap_priv->base.fbo;
|
fbo = pixmap_priv->base.fbo;
|
||||||
if (fbo == NULL)
|
if (fbo == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
pixmap_priv->base.fbo = NULL;
|
pixmap_priv->base.fbo = NULL;
|
||||||
return fbo;
|
return fbo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The pixmap must not be attached to another fbo. */
|
/* The pixmap must not be attached to another fbo. */
|
||||||
void
|
void
|
||||||
glamor_pixmap_attach_fbo(PixmapPtr pixmap, glamor_pixmap_fbo *fbo)
|
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)
|
if (pixmap_priv->base.fbo)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pixmap_priv->base.fbo = fbo;
|
pixmap_priv->base.fbo = fbo;
|
||||||
|
|
||||||
switch (pixmap_priv->type) {
|
switch (pixmap_priv->type) {
|
||||||
case GLAMOR_TEXTURE_LARGE:
|
case GLAMOR_TEXTURE_LARGE:
|
||||||
case GLAMOR_TEXTURE_ONLY:
|
case GLAMOR_TEXTURE_ONLY:
|
||||||
case GLAMOR_TEXTURE_DRM:
|
case GLAMOR_TEXTURE_DRM:
|
||||||
pixmap_priv->base.gl_fbo = 1;
|
pixmap_priv->base.gl_fbo = 1;
|
||||||
if (fbo->tex != 0)
|
if (fbo->tex != 0)
|
||||||
pixmap_priv->base.gl_tex = 1;
|
pixmap_priv->base.gl_tex = 1;
|
||||||
else {
|
else {
|
||||||
/* XXX For the Xephyr only, may be broken now.*/
|
/* XXX For the Xephyr only, may be broken now. */
|
||||||
pixmap_priv->base.gl_tex = 0;
|
pixmap_priv->base.gl_tex = 0;
|
||||||
}
|
}
|
||||||
case GLAMOR_MEMORY_MAP:
|
case GLAMOR_MEMORY_MAP:
|
||||||
pixmap->devPrivate.ptr = NULL;
|
pixmap->devPrivate.ptr = NULL;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_pixmap_destroy_fbo(glamor_pixmap_private *priv)
|
glamor_pixmap_destroy_fbo(glamor_pixmap_private *priv)
|
||||||
{
|
{
|
||||||
glamor_pixmap_fbo *fbo;
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
Bool
|
||||||
glamor_pixmap_ensure_fbo(PixmapPtr pixmap, GLenum format, int flag)
|
glamor_pixmap_ensure_fbo(PixmapPtr pixmap, GLenum format, int flag)
|
||||||
{
|
{
|
||||||
glamor_screen_private *glamor_priv;
|
glamor_screen_private *glamor_priv;
|
||||||
glamor_pixmap_private *pixmap_priv;
|
glamor_pixmap_private *pixmap_priv;
|
||||||
glamor_pixmap_fbo *fbo;
|
glamor_pixmap_fbo *fbo;
|
||||||
|
|
||||||
glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
|
glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||||
if (pixmap_priv->base.fbo == NULL) {
|
if (pixmap_priv->base.fbo == NULL) {
|
||||||
|
|
||||||
fbo = glamor_create_fbo(glamor_priv, pixmap->drawable.width,
|
fbo = glamor_create_fbo(glamor_priv, pixmap->drawable.width,
|
||||||
pixmap->drawable.height,
|
pixmap->drawable.height, format, flag);
|
||||||
format,
|
if (fbo == NULL)
|
||||||
flag);
|
return FALSE;
|
||||||
if (fbo == NULL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
glamor_pixmap_attach_fbo(pixmap, fbo);
|
glamor_pixmap_attach_fbo(pixmap, fbo);
|
||||||
} else {
|
}
|
||||||
/* We do have a fbo, but it may lack of fb or tex. */
|
else {
|
||||||
if (!pixmap_priv->base.fbo->tex)
|
/* We do have a fbo, but it may lack of fb or tex. */
|
||||||
pixmap_priv->base.fbo->tex = _glamor_create_tex(glamor_priv, pixmap->drawable.width,
|
if (!pixmap_priv->base.fbo->tex)
|
||||||
pixmap->drawable.height, format);
|
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)
|
if (flag != GLAMOR_CREATE_FBO_NO_FBO && pixmap_priv->base.fbo->fb == 0)
|
||||||
glamor_pixmap_ensure_fb(pixmap_priv->base.fbo);
|
glamor_pixmap_ensure_fb(pixmap_priv->base.fbo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
_X_EXPORT void
|
_X_EXPORT void
|
||||||
glamor_pixmap_exchange_fbos(PixmapPtr front, PixmapPtr back)
|
glamor_pixmap_exchange_fbos(PixmapPtr front, PixmapPtr back)
|
||||||
{
|
{
|
||||||
glamor_pixmap_private *front_priv, *back_priv;
|
glamor_pixmap_private *front_priv, *back_priv;
|
||||||
glamor_pixmap_fbo *temp_fbo;
|
glamor_pixmap_fbo *temp_fbo;
|
||||||
|
|
||||||
front_priv = glamor_get_pixmap_private(front);
|
front_priv = glamor_get_pixmap_private(front);
|
||||||
back_priv = glamor_get_pixmap_private(back);
|
back_priv = glamor_get_pixmap_private(back);
|
||||||
temp_fbo = front_priv->base.fbo;
|
temp_fbo = front_priv->base.fbo;
|
||||||
front_priv->base.fbo = back_priv->base.fbo;
|
front_priv->base.fbo = back_priv->base.fbo;
|
||||||
back_priv->base.fbo = temp_fbo;
|
back_priv->base.fbo = temp_fbo;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,332 +33,325 @@
|
||||||
*/
|
*/
|
||||||
Bool
|
Bool
|
||||||
glamor_fill(DrawablePtr drawable,
|
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);
|
PixmapPtr dst_pixmap = glamor_get_drawable_pixmap(drawable);
|
||||||
int off_x, off_y;
|
int off_x, off_y;
|
||||||
PixmapPtr sub_pixmap = NULL;
|
PixmapPtr sub_pixmap = NULL;
|
||||||
glamor_access_t sub_pixmap_access;
|
glamor_access_t sub_pixmap_access;
|
||||||
DrawablePtr saved_drawable = NULL;
|
DrawablePtr saved_drawable = NULL;
|
||||||
int saved_x = x, saved_y = y;
|
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) {
|
switch (gc->fillStyle) {
|
||||||
case FillSolid:
|
case FillSolid:
|
||||||
if (!glamor_solid(dst_pixmap,
|
if (!glamor_solid(dst_pixmap,
|
||||||
x + off_x,
|
x + off_x,
|
||||||
y + off_y,
|
y + off_y,
|
||||||
width, height, gc->alu, gc->planemask,
|
width, height, gc->alu, gc->planemask, gc->fgPixel))
|
||||||
gc->fgPixel))
|
goto fail;
|
||||||
goto fail;
|
break;
|
||||||
break;
|
case FillStippled:
|
||||||
case FillStippled:
|
case FillOpaqueStippled:
|
||||||
case FillOpaqueStippled:
|
if (!glamor_stipple(dst_pixmap,
|
||||||
if (!glamor_stipple(dst_pixmap,
|
gc->stipple,
|
||||||
gc->stipple,
|
x + off_x,
|
||||||
x + off_x,
|
y + off_y,
|
||||||
y + off_y,
|
width,
|
||||||
width,
|
height,
|
||||||
height,
|
gc->alu,
|
||||||
gc->alu,
|
gc->planemask,
|
||||||
gc->planemask,
|
gc->fgPixel,
|
||||||
gc->fgPixel,
|
gc->bgPixel, gc->patOrg.x, gc->patOrg.y))
|
||||||
gc->bgPixel, gc->patOrg.x,
|
goto fail;
|
||||||
gc->patOrg.y))
|
break;
|
||||||
goto fail;
|
case FillTiled:
|
||||||
break;
|
if (!glamor_tile(dst_pixmap,
|
||||||
case FillTiled:
|
gc->tile.pixmap,
|
||||||
if (!glamor_tile(dst_pixmap,
|
x + off_x,
|
||||||
gc->tile.pixmap,
|
y + off_y,
|
||||||
x + off_x,
|
width,
|
||||||
y + off_y,
|
height,
|
||||||
width,
|
gc->alu,
|
||||||
height,
|
gc->planemask,
|
||||||
gc->alu,
|
x - drawable->x - gc->patOrg.x,
|
||||||
gc->planemask,
|
y - drawable->y - gc->patOrg.y))
|
||||||
x - drawable->x - gc->patOrg.x,
|
goto fail;
|
||||||
y - drawable->y - gc->patOrg.y))
|
break;
|
||||||
goto fail;
|
}
|
||||||
break;
|
return TRUE;
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
if (!fallback) {
|
if (!fallback) {
|
||||||
if (glamor_ddx_fallback_check_pixmap(&dst_pixmap->drawable)
|
if (glamor_ddx_fallback_check_pixmap(&dst_pixmap->drawable)
|
||||||
&& glamor_ddx_fallback_check_gc(gc))
|
&& glamor_ddx_fallback_check_gc(gc))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
/* Is it possible to set the access as WO? */
|
/* 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,
|
sub_pixmap = glamor_get_sub_pixmap(dst_pixmap, x + off_x,
|
||||||
y + off_y, width, height,
|
y + off_y, width, height,
|
||||||
sub_pixmap_access);
|
sub_pixmap_access);
|
||||||
|
|
||||||
if (sub_pixmap != NULL) {
|
if (sub_pixmap != NULL) {
|
||||||
if (gc->fillStyle != FillSolid) {
|
if (gc->fillStyle != FillSolid) {
|
||||||
gc->patOrg.x += (drawable->x - x);
|
gc->patOrg.x += (drawable->x - x);
|
||||||
gc->patOrg.y += (drawable->y - y);
|
gc->patOrg.y += (drawable->y - y);
|
||||||
}
|
}
|
||||||
saved_drawable = drawable;
|
saved_drawable = drawable;
|
||||||
drawable = &sub_pixmap->drawable;
|
drawable = &sub_pixmap->drawable;
|
||||||
saved_x = x;
|
saved_x = x;
|
||||||
saved_y = y;
|
saved_y = y;
|
||||||
x = 0;
|
x = 0;
|
||||||
y = 0;
|
y = 0;
|
||||||
}
|
}
|
||||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||||
if (glamor_prepare_access_gc(gc)) {
|
if (glamor_prepare_access_gc(gc)) {
|
||||||
fbFill(drawable, gc, x, y, width, height);
|
fbFill(drawable, gc, x, y, width, height);
|
||||||
glamor_finish_access_gc(gc);
|
glamor_finish_access_gc(gc);
|
||||||
}
|
}
|
||||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sub_pixmap != NULL) {
|
if (sub_pixmap != NULL) {
|
||||||
if (gc->fillStyle != FillSolid) {
|
if (gc->fillStyle != FillSolid) {
|
||||||
gc->patOrg.x -= (saved_drawable->x - saved_x);
|
gc->patOrg.x -= (saved_drawable->x - saved_x);
|
||||||
gc->patOrg.y -= (saved_drawable->y - saved_y);
|
gc->patOrg.y -= (saved_drawable->y - saved_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
x = saved_x;
|
x = saved_x;
|
||||||
y = saved_y;
|
y = saved_y;
|
||||||
|
|
||||||
glamor_put_sub_pixmap(sub_pixmap, dst_pixmap,
|
glamor_put_sub_pixmap(sub_pixmap, dst_pixmap,
|
||||||
x + off_x, y + off_y,
|
x + off_x, y + off_y,
|
||||||
width, height, sub_pixmap_access);
|
width, height, sub_pixmap_access);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_init_solid_shader(ScreenPtr screen)
|
glamor_init_solid_shader(ScreenPtr screen)
|
||||||
{
|
{
|
||||||
glamor_screen_private *glamor_priv;
|
glamor_screen_private *glamor_priv;
|
||||||
glamor_gl_dispatch *dispatch;
|
glamor_gl_dispatch *dispatch;
|
||||||
const char *solid_vs =
|
const char *solid_vs =
|
||||||
"attribute vec4 v_position;"
|
"attribute vec4 v_position;"
|
||||||
"void main()\n" "{\n" " gl_Position = v_position;\n"
|
"void main()\n"
|
||||||
"}\n";
|
"{\n"
|
||||||
const char *solid_fs =
|
" gl_Position = v_position;\n"
|
||||||
GLAMOR_DEFAULT_PRECISION "uniform vec4 color;\n"
|
"}\n";
|
||||||
"void main()\n" "{\n" " gl_FragColor = color;\n" "}\n";
|
const char *solid_fs =
|
||||||
GLint fs_prog, vs_prog;
|
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);
|
glamor_priv = glamor_get_screen_private(screen);
|
||||||
dispatch = glamor_get_dispatch(glamor_priv);
|
dispatch = glamor_get_dispatch(glamor_priv);
|
||||||
glamor_priv->solid_prog = dispatch->glCreateProgram();
|
glamor_priv->solid_prog = dispatch->glCreateProgram();
|
||||||
vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, solid_vs);
|
vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, solid_vs);
|
||||||
fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
|
fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER, solid_fs);
|
||||||
solid_fs);
|
dispatch->glAttachShader(glamor_priv->solid_prog, vs_prog);
|
||||||
dispatch->glAttachShader(glamor_priv->solid_prog, vs_prog);
|
dispatch->glAttachShader(glamor_priv->solid_prog, fs_prog);
|
||||||
dispatch->glAttachShader(glamor_priv->solid_prog, fs_prog);
|
|
||||||
|
|
||||||
dispatch->glBindAttribLocation(glamor_priv->solid_prog,
|
dispatch->glBindAttribLocation(glamor_priv->solid_prog,
|
||||||
GLAMOR_VERTEX_POS, "v_position");
|
GLAMOR_VERTEX_POS, "v_position");
|
||||||
glamor_link_glsl_prog(dispatch, glamor_priv->solid_prog);
|
glamor_link_glsl_prog(dispatch, glamor_priv->solid_prog);
|
||||||
|
|
||||||
glamor_priv->solid_color_uniform_location =
|
glamor_priv->solid_color_uniform_location =
|
||||||
dispatch->glGetUniformLocation(glamor_priv->solid_prog,
|
dispatch->glGetUniformLocation(glamor_priv->solid_prog, "color");
|
||||||
"color");
|
glamor_put_dispatch(glamor_priv);
|
||||||
glamor_put_dispatch(glamor_priv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_fini_solid_shader(ScreenPtr screen)
|
glamor_fini_solid_shader(ScreenPtr screen)
|
||||||
{
|
{
|
||||||
glamor_screen_private *glamor_priv;
|
glamor_screen_private *glamor_priv;
|
||||||
glamor_gl_dispatch *dispatch;
|
glamor_gl_dispatch *dispatch;
|
||||||
|
|
||||||
glamor_priv = glamor_get_screen_private(screen);
|
glamor_priv = glamor_get_screen_private(screen);
|
||||||
dispatch = glamor_get_dispatch(glamor_priv);
|
dispatch = glamor_get_dispatch(glamor_priv);
|
||||||
dispatch->glDeleteProgram(glamor_priv->solid_prog);
|
dispatch->glDeleteProgram(glamor_priv->solid_prog);
|
||||||
glamor_put_dispatch(glamor_priv);
|
glamor_put_dispatch(glamor_priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
|
_glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
|
||||||
{
|
{
|
||||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||||
glamor_screen_private *glamor_priv =
|
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||||
glamor_get_screen_private(screen);
|
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||||
glamor_pixmap_private *pixmap_priv =
|
glamor_gl_dispatch *dispatch;
|
||||||
glamor_get_pixmap_private(pixmap);
|
GLfloat xscale, yscale;
|
||||||
glamor_gl_dispatch *dispatch;
|
float vertices[32];
|
||||||
GLfloat xscale, yscale;
|
float *pvertices = vertices;
|
||||||
float vertices[32];
|
int valid_nbox = ARRAY_SIZE(vertices);
|
||||||
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 = glamor_get_dispatch(glamor_priv);
|
||||||
dispatch->glUseProgram(glamor_priv->solid_prog);
|
dispatch->glUseProgram(glamor_priv->solid_prog);
|
||||||
|
|
||||||
dispatch->glUniform4fv(glamor_priv->solid_color_uniform_location,
|
dispatch->glUniform4fv(glamor_priv->solid_color_uniform_location, 1, color);
|
||||||
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))) {
|
if (_X_UNLIKELY(nbox * 4 * 2 > ARRAY_SIZE(vertices))) {
|
||||||
int allocated_box;
|
int allocated_box;
|
||||||
|
|
||||||
if (nbox * 6 > GLAMOR_COMPOSITE_VBO_VERT_CNT) {
|
if (nbox * 6 > GLAMOR_COMPOSITE_VBO_VERT_CNT) {
|
||||||
allocated_box = GLAMOR_COMPOSITE_VBO_VERT_CNT / 6;
|
allocated_box = GLAMOR_COMPOSITE_VBO_VERT_CNT / 6;
|
||||||
} else
|
}
|
||||||
allocated_box = nbox;
|
else
|
||||||
pvertices = malloc(allocated_box * 4 * 2 * sizeof(float));
|
allocated_box = nbox;
|
||||||
if (pvertices)
|
pvertices = malloc(allocated_box * 4 * 2 * sizeof(float));
|
||||||
valid_nbox = allocated_box;
|
if (pvertices)
|
||||||
else {
|
valid_nbox = allocated_box;
|
||||||
pvertices = vertices;
|
else {
|
||||||
valid_nbox = ARRAY_SIZE(vertices) / (4*2);
|
pvertices = vertices;
|
||||||
}
|
valid_nbox = ARRAY_SIZE(vertices) / (4 * 2);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (unlikely(nbox > 1))
|
if (_X_UNLIKELY(nbox > 1))
|
||||||
dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo);
|
dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo);
|
||||||
|
|
||||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||||
GL_FALSE, 2 * sizeof(float),
|
GL_FALSE, 2 * sizeof(float), pvertices);
|
||||||
pvertices);
|
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
|
||||||
|
|
||||||
while(nbox) {
|
while (nbox) {
|
||||||
int box_cnt, i;
|
int box_cnt, i;
|
||||||
float *valid_vertices;
|
float *valid_vertices;
|
||||||
valid_vertices = pvertices;
|
|
||||||
box_cnt = nbox > valid_nbox ? valid_nbox : nbox;
|
valid_vertices = pvertices;
|
||||||
for (i = 0; i < box_cnt; i++) {
|
box_cnt = nbox > valid_nbox ? valid_nbox : nbox;
|
||||||
glamor_set_normalize_vcoords(pixmap_priv, xscale, yscale,
|
for (i = 0; i < box_cnt; i++) {
|
||||||
box[i].x1, box[i].y1,
|
glamor_set_normalize_vcoords(pixmap_priv, xscale, yscale,
|
||||||
box[i].x2, box[i].y2,
|
box[i].x1, box[i].y1,
|
||||||
glamor_priv->yInverted,
|
box[i].x2, box[i].y2,
|
||||||
valid_vertices);
|
glamor_priv->yInverted,
|
||||||
valid_vertices += 4*2;
|
valid_vertices);
|
||||||
}
|
valid_vertices += 4 * 2;
|
||||||
if (box_cnt == 1)
|
}
|
||||||
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, box_cnt * 4);
|
if (box_cnt == 1)
|
||||||
else
|
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, box_cnt * 4);
|
||||||
|
else
|
||||||
#ifndef GLAMOR_GLES2
|
#ifndef GLAMOR_GLES2
|
||||||
dispatch->glDrawRangeElements(GL_TRIANGLES,
|
dispatch->glDrawRangeElements(GL_TRIANGLES,
|
||||||
0,
|
0,
|
||||||
box_cnt * 4,
|
box_cnt * 4,
|
||||||
box_cnt * 6,
|
box_cnt * 6, GL_UNSIGNED_SHORT, NULL);
|
||||||
GL_UNSIGNED_SHORT,
|
|
||||||
NULL);
|
|
||||||
#else
|
#else
|
||||||
dispatch->glDrawElements(GL_TRIANGLES,
|
dispatch->glDrawElements(GL_TRIANGLES,
|
||||||
box_cnt * 6,
|
box_cnt * 6, GL_UNSIGNED_SHORT, NULL);
|
||||||
GL_UNSIGNED_SHORT,
|
|
||||||
NULL);
|
|
||||||
#endif
|
#endif
|
||||||
nbox -= box_cnt;
|
nbox -= box_cnt;
|
||||||
box += box_cnt;
|
box += box_cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pvertices != vertices)
|
if (pvertices != vertices)
|
||||||
free(pvertices);
|
free(pvertices);
|
||||||
|
|
||||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||||
dispatch->glUseProgram(0);
|
dispatch->glUseProgram(0);
|
||||||
glamor_put_dispatch(glamor_priv);
|
glamor_put_dispatch(glamor_priv);
|
||||||
glamor_priv->state = RENDER_STATE;
|
glamor_priv->state = RENDER_STATE;
|
||||||
glamor_priv->render_idle_cnt = 0;
|
glamor_priv->render_idle_cnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
glamor_solid_boxes(PixmapPtr pixmap,
|
glamor_solid_boxes(PixmapPtr pixmap,
|
||||||
BoxPtr box, int nbox,
|
BoxPtr box, int nbox, unsigned long fg_pixel)
|
||||||
unsigned long fg_pixel)
|
|
||||||
{
|
{
|
||||||
glamor_pixmap_private *pixmap_priv;
|
glamor_pixmap_private *pixmap_priv;
|
||||||
GLfloat color[4];
|
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))
|
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
glamor_get_rgba_from_pixel(fg_pixel,
|
glamor_get_rgba_from_pixel(fg_pixel,
|
||||||
&color[0],
|
&color[0],
|
||||||
&color[1],
|
&color[1],
|
||||||
&color[2],
|
&color[2], &color[3], format_for_pixmap(pixmap));
|
||||||
&color[3], format_for_pixmap(pixmap));
|
|
||||||
|
|
||||||
if (pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
if (pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||||
RegionRec region;
|
RegionRec region;
|
||||||
int n_region;
|
int n_region;
|
||||||
glamor_pixmap_clipped_regions *clipped_regions;
|
glamor_pixmap_clipped_regions *clipped_regions;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
RegionInitBoxes(®ion, box, nbox);
|
RegionInitBoxes(®ion, box, nbox);
|
||||||
clipped_regions = glamor_compute_clipped_regions(pixmap_priv, ®ion, &n_region, 0, 0, 0);
|
clipped_regions =
|
||||||
for(i = 0; i < n_region; i++)
|
glamor_compute_clipped_regions(pixmap_priv, ®ion, &n_region, 0,
|
||||||
{
|
0, 0);
|
||||||
BoxPtr inner_box;
|
for (i = 0; i < n_region; i++) {
|
||||||
int inner_nbox;
|
BoxPtr inner_box;
|
||||||
SET_PIXMAP_FBO_CURRENT(pixmap_priv, clipped_regions[i].block_idx);
|
int inner_nbox;
|
||||||
|
|
||||||
inner_box = RegionRects(clipped_regions[i].region);
|
SET_PIXMAP_FBO_CURRENT(pixmap_priv, clipped_regions[i].block_idx);
|
||||||
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;
|
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
|
Bool
|
||||||
glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
|
glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
|
||||||
unsigned char alu, unsigned long planemask,
|
unsigned char alu, unsigned long planemask, unsigned long fg_pixel)
|
||||||
unsigned long fg_pixel)
|
|
||||||
{
|
{
|
||||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||||
glamor_screen_private *glamor_priv =
|
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||||
glamor_get_screen_private(screen);
|
glamor_pixmap_private *pixmap_priv;
|
||||||
glamor_pixmap_private *pixmap_priv;
|
glamor_gl_dispatch *dispatch;
|
||||||
glamor_gl_dispatch *dispatch;
|
BoxRec box;
|
||||||
BoxRec box;
|
|
||||||
|
|
||||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||||
|
|
||||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!glamor_set_planemask(pixmap, planemask)) {
|
if (!glamor_set_planemask(pixmap, planemask)) {
|
||||||
glamor_fallback
|
glamor_fallback("Failedto set planemask in glamor_solid.\n");
|
||||||
("Failedto set planemask in glamor_solid.\n");
|
return FALSE;
|
||||||
return FALSE;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
dispatch = glamor_get_dispatch(glamor_priv);
|
dispatch = glamor_get_dispatch(glamor_priv);
|
||||||
if (!glamor_set_alu(dispatch, alu)) {
|
if (!glamor_set_alu(dispatch, alu)) {
|
||||||
if (alu == GXclear)
|
if (alu == GXclear)
|
||||||
fg_pixel = 0;
|
fg_pixel = 0;
|
||||||
else {
|
else {
|
||||||
glamor_fallback("unsupported alu %x\n", alu);
|
glamor_fallback("unsupported alu %x\n", alu);
|
||||||
glamor_put_dispatch(glamor_priv);
|
glamor_put_dispatch(glamor_priv);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
box.x1 = x;
|
box.x1 = x;
|
||||||
box.y1 = y;
|
box.y1 = y;
|
||||||
box.x2 = x + width;
|
box.x2 = x + width;
|
||||||
box.y2 = y + height;
|
box.y2 = y + height;
|
||||||
glamor_solid_boxes(pixmap, &box, 1, fg_pixel);
|
glamor_solid_boxes(pixmap, &box, 1, fg_pixel);
|
||||||
|
|
||||||
glamor_set_alu(dispatch, GXcopy);
|
glamor_set_alu(dispatch, GXcopy);
|
||||||
glamor_put_dispatch(glamor_priv);
|
glamor_put_dispatch(glamor_priv);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,86 +28,81 @@
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
_glamor_fill_spans(DrawablePtr drawable,
|
_glamor_fill_spans(DrawablePtr drawable,
|
||||||
GCPtr gc,
|
GCPtr gc,
|
||||||
int n, DDXPointPtr points, int *widths, int sorted, Bool fallback)
|
int n, DDXPointPtr points, int *widths, int sorted,
|
||||||
|
Bool fallback)
|
||||||
{
|
{
|
||||||
DDXPointPtr ppt;
|
DDXPointPtr ppt;
|
||||||
int nbox;
|
int nbox;
|
||||||
BoxPtr pbox;
|
BoxPtr pbox;
|
||||||
int x1, x2, y;
|
int x1, x2, y;
|
||||||
RegionPtr pClip = fbGetCompositeClip(gc);
|
RegionPtr pClip = fbGetCompositeClip(gc);
|
||||||
Bool ret = FALSE;
|
Bool ret = FALSE;
|
||||||
|
|
||||||
if (gc->fillStyle != FillSolid && gc->fillStyle != FillTiled)
|
if (gc->fillStyle != FillSolid && gc->fillStyle != FillTiled)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
ppt = points;
|
ppt = points;
|
||||||
while (n--) {
|
while (n--) {
|
||||||
x1 = ppt->x;
|
x1 = ppt->x;
|
||||||
y = ppt->y;
|
y = ppt->y;
|
||||||
x2 = x1 + (int) *widths;
|
x2 = x1 + (int) *widths;
|
||||||
ppt++;
|
ppt++;
|
||||||
widths++;
|
widths++;
|
||||||
|
|
||||||
nbox = REGION_NUM_RECTS(pClip);
|
nbox = REGION_NUM_RECTS(pClip);
|
||||||
pbox = REGION_RECTS(pClip);
|
pbox = REGION_RECTS(pClip);
|
||||||
while (nbox--) {
|
while (nbox--) {
|
||||||
int real_x1 = x1, real_x2 = x2;
|
int real_x1 = x1, real_x2 = x2;
|
||||||
|
|
||||||
if (real_x1 < pbox->x1)
|
if (real_x1 < pbox->x1)
|
||||||
real_x1 = pbox->x1;
|
real_x1 = pbox->x1;
|
||||||
|
|
||||||
if (real_x2 > pbox->x2)
|
if (real_x2 > pbox->x2)
|
||||||
real_x2 = pbox->x2;
|
real_x2 = pbox->x2;
|
||||||
|
|
||||||
if (real_x2 > real_x1 && pbox->y1 <= y && pbox->y2 > y) {
|
if (real_x2 > real_x1 && pbox->y1 <= y && pbox->y2 > y) {
|
||||||
if (!glamor_fill(drawable, gc, real_x1, y,
|
if (!glamor_fill(drawable, gc, real_x1, y,
|
||||||
real_x2 - real_x1, 1, fallback))
|
real_x2 - real_x1, 1, fallback))
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
pbox++;
|
pbox++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
if (!fallback
|
if (!fallback && glamor_ddx_fallback_check_pixmap(drawable)
|
||||||
&& glamor_ddx_fallback_check_pixmap(drawable)
|
&& glamor_ddx_fallback_check_gc(gc)) {
|
||||||
&& glamor_ddx_fallback_check_gc(gc)) {
|
goto done;
|
||||||
goto done;
|
}
|
||||||
}
|
glamor_fallback("to %p (%c)\n", drawable,
|
||||||
glamor_fallback("to %p (%c)\n", drawable,
|
glamor_get_drawable_location(drawable));
|
||||||
glamor_get_drawable_location(drawable));
|
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
if (glamor_prepare_access_gc(gc)) {
|
||||||
if (glamor_prepare_access_gc(gc)) {
|
fbFillSpans(drawable, gc, n, points, widths, sorted);
|
||||||
fbFillSpans(drawable, gc, n, points, widths,
|
glamor_finish_access_gc(gc);
|
||||||
sorted);
|
}
|
||||||
glamor_finish_access_gc(gc);
|
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
||||||
}
|
}
|
||||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
ret = TRUE;
|
||||||
}
|
|
||||||
ret = TRUE;
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_fill_spans(DrawablePtr drawable,
|
glamor_fill_spans(DrawablePtr drawable,
|
||||||
GCPtr gc,
|
GCPtr gc, int n, DDXPointPtr points, int *widths, int sorted)
|
||||||
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
|
Bool
|
||||||
glamor_fill_spans_nf(DrawablePtr drawable,
|
glamor_fill_spans_nf(DrawablePtr drawable,
|
||||||
GCPtr gc,
|
GCPtr gc,
|
||||||
int n, DDXPointPtr points, int *widths, int sorted)
|
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"
|
#include "glamor_priv.h"
|
||||||
|
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
_glamor_get_image(DrawablePtr drawable, int x, int y, int w, int h,
|
_glamor_get_image(DrawablePtr drawable, int x, int y, int w, int h,
|
||||||
unsigned int format, unsigned long planeMask, char *d,
|
unsigned int format, unsigned long planeMask, char *d,
|
||||||
Bool fallback)
|
Bool fallback)
|
||||||
{
|
{
|
||||||
PixmapPtr pixmap, sub_pixmap;
|
PixmapPtr pixmap, sub_pixmap;
|
||||||
struct glamor_pixmap_private *pixmap_priv;
|
struct glamor_pixmap_private *pixmap_priv;
|
||||||
int x_off, y_off;
|
int x_off, y_off;
|
||||||
int stride;
|
int stride;
|
||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
pixmap = glamor_get_drawable_pixmap(drawable);
|
pixmap = glamor_get_drawable_pixmap(drawable);
|
||||||
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
|
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
|
||||||
|
|
||||||
if (format != ZPixmap)
|
if (format != ZPixmap)
|
||||||
goto fall_back;
|
goto fall_back;
|
||||||
pixmap = glamor_get_drawable_pixmap(drawable);
|
pixmap = glamor_get_drawable_pixmap(drawable);
|
||||||
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
|
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
|
||||||
|
|
||||||
if (!glamor_set_planemask(pixmap, planeMask)) {
|
if (!glamor_set_planemask(pixmap, planeMask)) {
|
||||||
glamor_fallback
|
glamor_fallback("Failedto set planemask in glamor_solid.\n");
|
||||||
("Failedto set planemask in glamor_solid.\n");
|
goto fall_back;
|
||||||
goto fall_back;
|
}
|
||||||
}
|
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||||
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))
|
x += drawable->x + x_off;
|
||||||
goto fall_back;
|
y += drawable->y + y_off;
|
||||||
stride = PixmapBytePad(w, drawable->depth);
|
|
||||||
|
|
||||||
x += drawable->x + x_off;
|
data = glamor_download_sub_pixmap_to_cpu(pixmap, x, y, w, h, stride,
|
||||||
y += drawable->y + y_off;
|
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,
|
return TRUE;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_get_image(DrawablePtr pDrawable, int x, int y, int w, int h,
|
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
|
Bool
|
||||||
glamor_get_image_nf(DrawablePtr pDrawable, int x, int y, int w, int h,
|
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,
|
return _glamor_get_image(pDrawable, x, y, w,
|
||||||
h, format, planeMask, d, FALSE);
|
h, format, planeMask, d, FALSE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,68 +28,65 @@
|
||||||
|
|
||||||
#include "glamor_priv.h"
|
#include "glamor_priv.h"
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
_glamor_get_spans(DrawablePtr drawable,
|
_glamor_get_spans(DrawablePtr drawable,
|
||||||
int wmax,
|
int wmax,
|
||||||
DDXPointPtr points, int *widths, int count, char *dst,
|
DDXPointPtr points, int *widths, int count, char *dst,
|
||||||
Bool fallback)
|
Bool fallback)
|
||||||
{
|
{
|
||||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||||
glamor_pixmap_private *pixmap_priv =
|
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||||
glamor_get_pixmap_private(pixmap);
|
int i;
|
||||||
int i;
|
uint8_t *readpixels_dst = (uint8_t *) dst;
|
||||||
uint8_t *readpixels_dst = (uint8_t *) dst;
|
void *data;
|
||||||
void *data;
|
int x_off, y_off;
|
||||||
int x_off, y_off;
|
Bool ret = FALSE;
|
||||||
Bool ret = FALSE;
|
|
||||||
|
|
||||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
|
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
data = glamor_download_sub_pixmap_to_cpu(pixmap, points[i].x + x_off,
|
data = glamor_download_sub_pixmap_to_cpu(pixmap, points[i].x + x_off,
|
||||||
points[i].y + y_off, widths[i], 1,
|
points[i].y + y_off, widths[i],
|
||||||
PixmapBytePad(widths[i], drawable->depth),
|
1, PixmapBytePad(widths[i],
|
||||||
readpixels_dst, 0, GLAMOR_ACCESS_RO);
|
drawable->
|
||||||
assert(data == readpixels_dst);
|
depth),
|
||||||
readpixels_dst += 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;
|
ret = TRUE;
|
||||||
goto done;
|
goto done;
|
||||||
fail:
|
fail:
|
||||||
|
|
||||||
if (!fallback
|
if (!fallback && glamor_ddx_fallback_check_pixmap(drawable))
|
||||||
&& glamor_ddx_fallback_check_pixmap(drawable))
|
goto done;
|
||||||
goto done;
|
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RO)) {
|
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RO)) {
|
||||||
fbGetSpans(drawable, wmax, points, widths, count, dst);
|
fbGetSpans(drawable, wmax, points, widths, count, dst);
|
||||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RO);
|
glamor_finish_access(drawable, GLAMOR_ACCESS_RO);
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_get_spans(DrawablePtr drawable,
|
glamor_get_spans(DrawablePtr drawable,
|
||||||
int wmax,
|
int wmax,
|
||||||
DDXPointPtr points, int *widths, int count, char *dst)
|
DDXPointPtr points, int *widths, int count, char *dst)
|
||||||
{
|
{
|
||||||
_glamor_get_spans(drawable, wmax, points,
|
_glamor_get_spans(drawable, wmax, points, widths, count, dst, TRUE);
|
||||||
widths, count, dst, TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
glamor_get_spans_nf(DrawablePtr drawable,
|
glamor_get_spans_nf(DrawablePtr drawable,
|
||||||
int wmax,
|
int wmax,
|
||||||
DDXPointPtr points, int *widths, int count, char *dst)
|
DDXPointPtr points, int *widths, int count, char *dst)
|
||||||
{
|
{
|
||||||
return _glamor_get_spans(drawable, wmax, points,
|
return _glamor_get_spans(drawable, wmax, points, widths, count, dst, FALSE);
|
||||||
widths, count, dst, FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,78 +41,78 @@
|
||||||
|
|
||||||
_X_EXPORT Bool
|
_X_EXPORT Bool
|
||||||
glamor_gl_dispatch_init_impl(struct glamor_gl_dispatch *dispatch,
|
glamor_gl_dispatch_init_impl(struct glamor_gl_dispatch *dispatch,
|
||||||
int gl_version,
|
int gl_version,
|
||||||
void *(*get_proc_address) (const char *))
|
void *(*get_proc_address) (const char *))
|
||||||
{
|
{
|
||||||
#ifndef GLAMOR_GLES2
|
#ifndef GLAMOR_GLES2
|
||||||
INIT_FUNC(dispatch, glMatrixMode, get_proc_address);
|
INIT_FUNC(dispatch, glMatrixMode, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glLoadIdentity, get_proc_address);
|
INIT_FUNC(dispatch, glLoadIdentity, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glRasterPos2i, get_proc_address);
|
INIT_FUNC(dispatch, glRasterPos2i, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glDrawPixels, get_proc_address);
|
INIT_FUNC(dispatch, glDrawPixels, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glLogicOp, get_proc_address);
|
INIT_FUNC(dispatch, glLogicOp, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glMapBuffer, get_proc_address);
|
INIT_FUNC(dispatch, glMapBuffer, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glMapBufferRange, get_proc_address);
|
INIT_FUNC(dispatch, glMapBufferRange, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glUnmapBuffer, get_proc_address);
|
INIT_FUNC(dispatch, glUnmapBuffer, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glBlitFramebuffer, get_proc_address);
|
INIT_FUNC(dispatch, glBlitFramebuffer, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glDrawRangeElements, get_proc_address);
|
INIT_FUNC(dispatch, glDrawRangeElements, get_proc_address);
|
||||||
#endif
|
#endif
|
||||||
INIT_FUNC(dispatch, glViewport, get_proc_address);
|
INIT_FUNC(dispatch, glViewport, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glDrawArrays, get_proc_address);
|
INIT_FUNC(dispatch, glDrawArrays, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glDrawElements, get_proc_address);
|
INIT_FUNC(dispatch, glDrawElements, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glReadPixels, get_proc_address);
|
INIT_FUNC(dispatch, glReadPixels, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glPixelStorei, get_proc_address);
|
INIT_FUNC(dispatch, glPixelStorei, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glTexParameteri, get_proc_address);
|
INIT_FUNC(dispatch, glTexParameteri, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glTexImage2D, get_proc_address);
|
INIT_FUNC(dispatch, glTexImage2D, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glGenTextures, get_proc_address);
|
INIT_FUNC(dispatch, glGenTextures, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glDeleteTextures, get_proc_address);
|
INIT_FUNC(dispatch, glDeleteTextures, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glBindTexture, get_proc_address);
|
INIT_FUNC(dispatch, glBindTexture, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glTexSubImage2D, get_proc_address);
|
INIT_FUNC(dispatch, glTexSubImage2D, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glFlush, get_proc_address);
|
INIT_FUNC(dispatch, glFlush, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glFinish, get_proc_address);
|
INIT_FUNC(dispatch, glFinish, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glGetIntegerv, get_proc_address);
|
INIT_FUNC(dispatch, glGetIntegerv, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glGetString, get_proc_address);
|
INIT_FUNC(dispatch, glGetString, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glScissor, get_proc_address);
|
INIT_FUNC(dispatch, glScissor, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glEnable, get_proc_address);
|
INIT_FUNC(dispatch, glEnable, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glDisable, get_proc_address);
|
INIT_FUNC(dispatch, glDisable, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glBlendFunc, get_proc_address);
|
INIT_FUNC(dispatch, glBlendFunc, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glActiveTexture, get_proc_address);
|
INIT_FUNC(dispatch, glActiveTexture, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glGenBuffers, get_proc_address);
|
INIT_FUNC(dispatch, glGenBuffers, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glBufferData, get_proc_address);
|
INIT_FUNC(dispatch, glBufferData, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glBindBuffer, get_proc_address);
|
INIT_FUNC(dispatch, glBindBuffer, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glDeleteBuffers, get_proc_address);
|
INIT_FUNC(dispatch, glDeleteBuffers, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glFramebufferTexture2D, get_proc_address);
|
INIT_FUNC(dispatch, glFramebufferTexture2D, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glBindFramebuffer, get_proc_address);
|
INIT_FUNC(dispatch, glBindFramebuffer, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glDeleteFramebuffers, get_proc_address);
|
INIT_FUNC(dispatch, glDeleteFramebuffers, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glGenFramebuffers, get_proc_address);
|
INIT_FUNC(dispatch, glGenFramebuffers, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glCheckFramebufferStatus, get_proc_address);
|
INIT_FUNC(dispatch, glCheckFramebufferStatus, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glVertexAttribPointer, get_proc_address);
|
INIT_FUNC(dispatch, glVertexAttribPointer, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glDisableVertexAttribArray, get_proc_address);
|
INIT_FUNC(dispatch, glDisableVertexAttribArray, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glEnableVertexAttribArray, get_proc_address);
|
INIT_FUNC(dispatch, glEnableVertexAttribArray, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glBindAttribLocation, get_proc_address);
|
INIT_FUNC(dispatch, glBindAttribLocation, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glLinkProgram, get_proc_address);
|
INIT_FUNC(dispatch, glLinkProgram, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glShaderSource, get_proc_address);
|
INIT_FUNC(dispatch, glShaderSource, get_proc_address);
|
||||||
|
|
||||||
INIT_FUNC(dispatch, glUseProgram, get_proc_address);
|
INIT_FUNC(dispatch, glUseProgram, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glUniform1i, get_proc_address);
|
INIT_FUNC(dispatch, glUniform1i, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glUniform1f, get_proc_address);
|
INIT_FUNC(dispatch, glUniform1f, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glUniform4f, get_proc_address);
|
INIT_FUNC(dispatch, glUniform4f, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glUniform4fv, get_proc_address);
|
INIT_FUNC(dispatch, glUniform4fv, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glUniform1fv, get_proc_address);
|
INIT_FUNC(dispatch, glUniform1fv, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glUniform2fv, get_proc_address);
|
INIT_FUNC(dispatch, glUniform2fv, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glUniformMatrix3fv, get_proc_address);
|
INIT_FUNC(dispatch, glUniformMatrix3fv, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glCreateProgram, get_proc_address);
|
INIT_FUNC(dispatch, glCreateProgram, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glDeleteProgram, get_proc_address);
|
INIT_FUNC(dispatch, glDeleteProgram, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glCreateShader, get_proc_address);
|
INIT_FUNC(dispatch, glCreateShader, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glCompileShader, get_proc_address);
|
INIT_FUNC(dispatch, glCompileShader, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glAttachShader, get_proc_address);
|
INIT_FUNC(dispatch, glAttachShader, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glDeleteShader, get_proc_address);
|
INIT_FUNC(dispatch, glDeleteShader, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glGetShaderiv, get_proc_address);
|
INIT_FUNC(dispatch, glGetShaderiv, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glGetShaderInfoLog, get_proc_address);
|
INIT_FUNC(dispatch, glGetShaderInfoLog, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glGetProgramiv, get_proc_address);
|
INIT_FUNC(dispatch, glGetProgramiv, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glGetProgramInfoLog, get_proc_address);
|
INIT_FUNC(dispatch, glGetProgramInfoLog, get_proc_address);
|
||||||
INIT_FUNC(dispatch, glGetUniformLocation, get_proc_address);
|
INIT_FUNC(dispatch, glGetUniformLocation, get_proc_address);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
fail:
|
fail:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,138 +1,128 @@
|
||||||
typedef struct glamor_gl_dispatch {
|
typedef struct glamor_gl_dispatch {
|
||||||
/* Transformation functions */
|
/* Transformation functions */
|
||||||
void (*glMatrixMode) (GLenum mode);
|
void (*glMatrixMode) (GLenum mode);
|
||||||
void (*glLoadIdentity) (void);
|
void (*glLoadIdentity) (void);
|
||||||
void (*glViewport) (GLint x, GLint y, GLsizei width,
|
void (*glViewport) (GLint x, GLint y, GLsizei width, GLsizei height);
|
||||||
GLsizei height);
|
/* Drawing functions */
|
||||||
/* Drawing functions */
|
void (*glRasterPos2i) (GLint x, GLint y);
|
||||||
void (*glRasterPos2i) (GLint x, GLint y);
|
|
||||||
|
|
||||||
/* Vertex Array */
|
/* Vertex Array */
|
||||||
void (*glDrawArrays) (GLenum mode, GLint first, GLsizei count);
|
void (*glDrawArrays) (GLenum mode, GLint first, GLsizei count);
|
||||||
|
|
||||||
/* Elements Array*/
|
/* Elements Array */
|
||||||
void (*glDrawElements) (GLenum mode, GLsizei count, GLenum type, const GLvoid * indices);
|
void (*glDrawElements) (GLenum mode, GLsizei count, GLenum type,
|
||||||
void (*glDrawRangeElements) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid * indices);
|
const GLvoid * indices);
|
||||||
|
void (*glDrawRangeElements) (GLenum mode, GLuint start, GLuint end,
|
||||||
|
GLsizei count, GLenum type,
|
||||||
|
const GLvoid * indices);
|
||||||
|
|
||||||
/* Raster functions */
|
/* Raster functions */
|
||||||
void (*glReadPixels) (GLint x, GLint y,
|
void (*glReadPixels) (GLint x, GLint y,
|
||||||
GLsizei width, GLsizei height,
|
GLsizei width, GLsizei height,
|
||||||
GLenum format, GLenum type, GLvoid * pixels);
|
GLenum format, GLenum type, GLvoid * pixels);
|
||||||
|
|
||||||
void (*glDrawPixels) (GLsizei width, GLsizei height,
|
void (*glDrawPixels) (GLsizei width, GLsizei height,
|
||||||
GLenum format, GLenum type,
|
GLenum format, GLenum type, const GLvoid * pixels);
|
||||||
const GLvoid * pixels);
|
void (*glPixelStorei) (GLenum pname, GLint param);
|
||||||
void (*glPixelStorei) (GLenum pname, GLint param);
|
/* Texture Mapping */
|
||||||
/* Texture Mapping */
|
|
||||||
|
|
||||||
void (*glTexParameteri) (GLenum target, GLenum pname, GLint param);
|
void (*glTexParameteri) (GLenum target, GLenum pname, GLint param);
|
||||||
void (*glTexImage2D) (GLenum target, GLint level,
|
void (*glTexImage2D) (GLenum target, GLint level,
|
||||||
GLint internalFormat,
|
GLint internalFormat,
|
||||||
GLsizei width, GLsizei height,
|
GLsizei width, GLsizei height,
|
||||||
GLint border, GLenum format, GLenum type,
|
GLint border, GLenum format, GLenum type,
|
||||||
const GLvoid * pixels);
|
const GLvoid * pixels);
|
||||||
/* 1.1 */
|
/* 1.1 */
|
||||||
void (*glGenTextures) (GLsizei n, GLuint * textures);
|
void (*glGenTextures) (GLsizei n, GLuint * textures);
|
||||||
void (*glDeleteTextures) (GLsizei n, const GLuint * textures);
|
void (*glDeleteTextures) (GLsizei n, const GLuint * textures);
|
||||||
void (*glBindTexture) (GLenum target, GLuint texture);
|
void (*glBindTexture) (GLenum target, GLuint texture);
|
||||||
void (*glTexSubImage2D) (GLenum target, GLint level,
|
void (*glTexSubImage2D) (GLenum target, GLint level,
|
||||||
GLint xoffset, GLint yoffset,
|
GLint xoffset, GLint yoffset,
|
||||||
GLsizei width, GLsizei height,
|
GLsizei width, GLsizei height,
|
||||||
GLenum format, GLenum type,
|
GLenum format, GLenum type, const GLvoid * pixels);
|
||||||
const GLvoid * pixels);
|
/* MISC */
|
||||||
/* MISC */
|
void (*glFlush) (void);
|
||||||
void (*glFlush) (void);
|
void (*glFinish) (void);
|
||||||
void (*glFinish) (void);
|
void (*glGetIntegerv) (GLenum pname, GLint * params);
|
||||||
void (*glGetIntegerv) (GLenum pname, GLint * params);
|
const GLubyte *(*glGetString) (GLenum name);
|
||||||
const GLubyte *(*glGetString) (GLenum name);
|
void (*glScissor) (GLint x, GLint y, GLsizei width, GLsizei height);
|
||||||
void (*glScissor) (GLint x, GLint y, GLsizei width,
|
void (*glEnable) (GLenum cap);
|
||||||
GLsizei height);
|
void (*glDisable) (GLenum cap);
|
||||||
void (*glEnable) (GLenum cap);
|
void (*glBlendFunc) (GLenum sfactor, GLenum dfactor);
|
||||||
void (*glDisable) (GLenum cap);
|
void (*glLogicOp) (GLenum opcode);
|
||||||
void (*glBlendFunc) (GLenum sfactor, GLenum dfactor);
|
|
||||||
void (*glLogicOp) (GLenum opcode);
|
|
||||||
|
|
||||||
/* 1.3 */
|
/* 1.3 */
|
||||||
void (*glActiveTexture) (GLenum texture);
|
void (*glActiveTexture) (GLenum texture);
|
||||||
|
|
||||||
/* GL Extentions */
|
/* GL Extentions */
|
||||||
void (*glGenBuffers) (GLsizei n, GLuint * buffers);
|
void (*glGenBuffers) (GLsizei n, GLuint * buffers);
|
||||||
void (*glBufferData) (GLenum target, GLsizeiptr size,
|
void (*glBufferData) (GLenum target, GLsizeiptr size,
|
||||||
const GLvoid * data, GLenum usage);
|
const GLvoid * data, GLenum usage);
|
||||||
GLvoid *(*glMapBuffer) (GLenum target, GLenum access);
|
GLvoid *(*glMapBuffer) (GLenum target, GLenum access);
|
||||||
GLvoid *(*glMapBufferRange) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
|
GLvoid *(*glMapBufferRange) (GLenum target, GLintptr offset,
|
||||||
GLboolean (*glUnmapBuffer) (GLenum target);
|
GLsizeiptr length, GLbitfield access);
|
||||||
void (*glBindBuffer) (GLenum target, GLuint buffer);
|
GLboolean(*glUnmapBuffer) (GLenum target);
|
||||||
void (*glDeleteBuffers) (GLsizei n, const GLuint * buffers);
|
void (*glBindBuffer) (GLenum target, GLuint buffer);
|
||||||
|
void (*glDeleteBuffers) (GLsizei n, const GLuint * buffers);
|
||||||
|
|
||||||
void (*glFramebufferTexture2D) (GLenum target, GLenum attachment,
|
void (*glFramebufferTexture2D) (GLenum target, GLenum attachment,
|
||||||
GLenum textarget, GLuint texture,
|
GLenum textarget, GLuint texture,
|
||||||
GLint level);
|
GLint level);
|
||||||
void (*glBindFramebuffer) (GLenum target, GLuint framebuffer);
|
void (*glBindFramebuffer) (GLenum target, GLuint framebuffer);
|
||||||
void (*glDeleteFramebuffers) (GLsizei n,
|
void (*glDeleteFramebuffers) (GLsizei n, const GLuint * framebuffers);
|
||||||
const GLuint * framebuffers);
|
void (*glGenFramebuffers) (GLsizei n, GLuint * framebuffers);
|
||||||
void (*glGenFramebuffers) (GLsizei n, GLuint * framebuffers);
|
GLenum(*glCheckFramebufferStatus) (GLenum target);
|
||||||
GLenum (*glCheckFramebufferStatus) (GLenum target);
|
void (*glBlitFramebuffer) (GLint srcX0, GLint srcY0, GLint srcX1,
|
||||||
void (*glBlitFramebuffer) (GLint srcX0, GLint srcY0, GLint srcX1,
|
GLint srcY1, GLint dstX0, GLint dstY0,
|
||||||
GLint srcY1, GLint dstX0, GLint dstY0,
|
GLint dstX1, GLint dstY1,
|
||||||
GLint dstX1, GLint dstY1,
|
GLbitfield mask, GLenum filter);
|
||||||
GLbitfield mask, GLenum filter);
|
|
||||||
|
|
||||||
void (*glVertexAttribPointer) (GLuint index, GLint size,
|
void (*glVertexAttribPointer) (GLuint index, GLint size,
|
||||||
GLenum type, GLboolean normalized,
|
GLenum type, GLboolean normalized,
|
||||||
GLsizei stride,
|
GLsizei stride, const GLvoid * pointer);
|
||||||
const GLvoid * pointer);
|
void (*glDisableVertexAttribArray) (GLuint index);
|
||||||
void (*glDisableVertexAttribArray) (GLuint index);
|
void (*glEnableVertexAttribArray) (GLuint index);
|
||||||
void (*glEnableVertexAttribArray) (GLuint index);
|
void (*glBindAttribLocation) (GLuint program, GLuint index,
|
||||||
void (*glBindAttribLocation) (GLuint program, GLuint index,
|
const GLchar * name);
|
||||||
const GLchar * name);
|
|
||||||
|
|
||||||
void (*glLinkProgram) (GLuint program);
|
void (*glLinkProgram) (GLuint program);
|
||||||
void (*glShaderSource) (GLuint shader, GLsizei count,
|
void (*glShaderSource) (GLuint shader, GLsizei count,
|
||||||
const GLchar * *string,
|
const GLchar * *string, const GLint * length);
|
||||||
const GLint * length);
|
void (*glUseProgram) (GLuint program);
|
||||||
void (*glUseProgram) (GLuint program);
|
void (*glUniform1i) (GLint location, GLint v0);
|
||||||
void (*glUniform1i) (GLint location, GLint v0);
|
void (*glUniform1f) (GLint location, GLfloat v0);
|
||||||
void (*glUniform1f) (GLint location, GLfloat v0);
|
void (*glUniform4f) (GLint location, GLfloat v0, GLfloat v1,
|
||||||
void (*glUniform4f) (GLint location, GLfloat v0, GLfloat v1,
|
GLfloat v2, GLfloat v3);
|
||||||
GLfloat v2, GLfloat v3);
|
void (*glUniform1fv) (GLint location, GLsizei count, const GLfloat * value);
|
||||||
void (*glUniform1fv) (GLint location, GLsizei count,
|
void (*glUniform2fv) (GLint location, GLsizei count, const GLfloat * value);
|
||||||
const GLfloat * value);
|
void (*glUniform4fv) (GLint location, GLsizei count, const GLfloat * value);
|
||||||
void (*glUniform2fv) (GLint location, GLsizei count,
|
void (*glUniformMatrix3fv) (GLint location, GLsizei count,
|
||||||
const GLfloat * value);
|
GLboolean transpose, const GLfloat * value);
|
||||||
void (*glUniform4fv) (GLint location, GLsizei count,
|
GLuint(*glCreateProgram) (void);
|
||||||
const GLfloat * value);
|
GLuint(*glDeleteProgram) (GLuint);
|
||||||
void (*glUniformMatrix3fv) (GLint location, GLsizei count,
|
GLuint(*glCreateShader) (GLenum type);
|
||||||
GLboolean transpose, const GLfloat* value);
|
void (*glCompileShader) (GLuint shader);
|
||||||
GLuint (*glCreateProgram) (void);
|
void (*glAttachShader) (GLuint program, GLuint shader);
|
||||||
GLuint (*glDeleteProgram) (GLuint);
|
void (*glDeleteShader) (GLuint shader);
|
||||||
GLuint (*glCreateShader) (GLenum type);
|
void (*glGetShaderiv) (GLuint shader, GLenum pname, GLint * params);
|
||||||
void (*glCompileShader) (GLuint shader);
|
void (*glGetShaderInfoLog) (GLuint shader, GLsizei bufSize,
|
||||||
void (*glAttachShader) (GLuint program, GLuint shader);
|
GLsizei * length, GLchar * infoLog);
|
||||||
void (*glDeleteShader) (GLuint shader);
|
void (*glGetProgramiv) (GLuint program, GLenum pname, GLint * params);
|
||||||
void (*glGetShaderiv) (GLuint shader, GLenum pname,
|
void (*glGetProgramInfoLog) (GLuint program, GLsizei bufSize,
|
||||||
GLint * params);
|
GLsizei * length, GLchar * infoLog);
|
||||||
void (*glGetShaderInfoLog) (GLuint shader, GLsizei bufSize,
|
GLint(*glGetUniformLocation) (GLuint program, const GLchar * name);
|
||||||
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;
|
} glamor_gl_dispatch;
|
||||||
|
|
||||||
|
|
||||||
typedef void *(*get_proc_address_t) (const char *);
|
typedef void *(*get_proc_address_t) (const char *);
|
||||||
|
|
||||||
_X_EXPORT Bool
|
_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
|
_X_EXPORT Bool
|
||||||
|
|
||||||
glamor_gl_dispatch_init(ScreenPtr screen,
|
glamor_gl_dispatch_init(ScreenPtr screen,
|
||||||
struct glamor_gl_dispatch *dispatch,
|
struct glamor_gl_dispatch *dispatch, int gl_version);
|
||||||
int gl_version);
|
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifdef GLAMOR_GLES2
|
#ifdef GLAMOR_GLES2
|
||||||
|
|
||||||
#define GL_BGRA GL_BGRA_EXT
|
#define GL_BGRA GL_BGRA_EXT
|
||||||
|
|
|
@ -30,89 +30,90 @@
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
_glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
_glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
||||||
int x, int y, unsigned int nglyph,
|
int x, int y, unsigned int nglyph,
|
||||||
CharInfoPtr * ppci, pointer pglyphBase, Bool fallback)
|
CharInfoPtr *ppci, void *pglyphBase, Bool fallback)
|
||||||
{
|
{
|
||||||
if (!fallback
|
if (!fallback && glamor_ddx_fallback_check_pixmap(pDrawable)
|
||||||
&& glamor_ddx_fallback_check_pixmap(pDrawable)
|
&& glamor_ddx_fallback_check_gc(pGC))
|
||||||
&& glamor_ddx_fallback_check_gc(pGC))
|
return FALSE;
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
miImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
|
miImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
||||||
int x, int y, unsigned int nglyph,
|
int x, int y, unsigned int nglyph,
|
||||||
CharInfoPtr * ppci, pointer pglyphBase)
|
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
|
Bool
|
||||||
glamor_image_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
|
glamor_image_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||||
int x, int y, unsigned int nglyph,
|
int x, int y, unsigned int nglyph,
|
||||||
CharInfoPtr * ppci, pointer pglyphBase)
|
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
|
static Bool
|
||||||
_glamor_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
_glamor_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
||||||
int x, int y, unsigned int nglyph,
|
int x, int y, unsigned int nglyph,
|
||||||
CharInfoPtr * ppci, pointer pglyphBase, Bool fallback)
|
CharInfoPtr *ppci, void *pglyphBase, Bool fallback)
|
||||||
{
|
{
|
||||||
if (!fallback
|
if (!fallback && glamor_ddx_fallback_check_pixmap(pDrawable)
|
||||||
&& glamor_ddx_fallback_check_pixmap(pDrawable)
|
&& glamor_ddx_fallback_check_gc(pGC))
|
||||||
&& glamor_ddx_fallback_check_gc(pGC))
|
return FALSE;
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
miPolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
|
miPolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
glamor_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
||||||
int x, int y, unsigned int nglyph,
|
int x, int y, unsigned int nglyph,
|
||||||
CharInfoPtr * ppci, pointer pglyphBase)
|
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
|
Bool
|
||||||
glamor_poly_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
|
glamor_poly_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||||
int x, int y, unsigned int nglyph,
|
int x, int y, unsigned int nglyph,
|
||||||
CharInfoPtr * ppci, pointer pglyphBase)
|
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
|
static Bool
|
||||||
_glamor_push_pixels(GCPtr pGC, PixmapPtr pBitmap,
|
_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
|
if (!fallback && glamor_ddx_fallback_check_pixmap(pDrawable)
|
||||||
&& glamor_ddx_fallback_check_pixmap(pDrawable)
|
&& glamor_ddx_fallback_check_pixmap(&pBitmap->drawable)
|
||||||
&& glamor_ddx_fallback_check_pixmap(&pBitmap->drawable)
|
&& glamor_ddx_fallback_check_gc(pGC))
|
||||||
&& glamor_ddx_fallback_check_gc(pGC))
|
return FALSE;
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
miPushPixels(pGC, pBitmap, pDrawable, w, h, x, y);
|
miPushPixels(pGC, pBitmap, pDrawable, w, h, x, y);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_push_pixels(GCPtr pGC, PixmapPtr pBitmap,
|
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
|
Bool
|
||||||
glamor_push_pixels_nf(GCPtr pGC, PixmapPtr pBitmap,
|
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
|
enum glamor_pixmap_status
|
||||||
glamor_upload_picture_to_texture(PicturePtr picture)
|
glamor_upload_picture_to_texture(PicturePtr picture)
|
||||||
{
|
{
|
||||||
PixmapPtr pixmap;
|
PixmapPtr pixmap;
|
||||||
assert(picture->pDrawable);
|
|
||||||
pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
|
|
||||||
|
|
||||||
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
|
Bool
|
||||||
glamor_prepare_access_picture(PicturePtr picture, glamor_access_t access)
|
glamor_prepare_access_picture(PicturePtr picture, glamor_access_t access)
|
||||||
{
|
{
|
||||||
if (!picture || !picture->pDrawable)
|
if (!picture || !picture->pDrawable)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
return glamor_prepare_access(picture->pDrawable, access);
|
return glamor_prepare_access(picture->pDrawable, access);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_finish_access_picture(PicturePtr picture, glamor_access_t access)
|
glamor_finish_access_picture(PicturePtr picture, glamor_access_t access)
|
||||||
{
|
{
|
||||||
if (!picture || !picture->pDrawable)
|
if (!picture || !picture->pDrawable)
|
||||||
return;
|
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
|
int
|
||||||
glamor_create_picture(PicturePtr picture)
|
glamor_create_picture(PicturePtr picture)
|
||||||
{
|
{
|
||||||
PixmapPtr pixmap;
|
PixmapPtr pixmap;
|
||||||
glamor_pixmap_private *pixmap_priv;
|
glamor_pixmap_private *pixmap_priv;
|
||||||
|
|
||||||
if (!picture || !picture->pDrawable)
|
if (!picture || !picture->pDrawable)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
|
pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
|
||||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||||
if (!pixmap_priv) {
|
if (!pixmap_priv) {
|
||||||
/* We must create a pixmap priv to track the picture format even
|
/* 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
|
* 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
|
* we may need to upload this pixmap to a texture on the fly. During
|
||||||
* the uploading, we need to know the picture format. */
|
* the uploading, we need to know the picture format. */
|
||||||
glamor_set_pixmap_type(pixmap, GLAMOR_MEMORY);
|
glamor_set_pixmap_type(pixmap, GLAMOR_MEMORY);
|
||||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||||
} else {
|
}
|
||||||
if (GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
|
else {
|
||||||
/* If the picture format is not compatible with glamor fbo format,
|
if (GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
|
||||||
* we have to mark this pixmap as a separated texture, and don't
|
/* If the picture format is not compatible with glamor fbo format,
|
||||||
* fallback to DDX layer. */
|
* we have to mark this pixmap as a separated texture, and don't
|
||||||
if (pixmap_priv->type == GLAMOR_TEXTURE_DRM
|
* fallback to DDX layer. */
|
||||||
&& !glamor_pict_format_is_compatible(picture->format,
|
if (pixmap_priv->type == GLAMOR_TEXTURE_DRM
|
||||||
pixmap->drawable.depth))
|
&& !glamor_pict_format_is_compatible(picture->format,
|
||||||
glamor_set_pixmap_type(pixmap, GLAMOR_SEPARATE_TEXTURE);
|
pixmap->drawable.depth))
|
||||||
}
|
glamor_set_pixmap_type(pixmap, GLAMOR_SEPARATE_TEXTURE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pixmap_priv->base.is_picture = 1;
|
pixmap_priv->base.is_picture = 1;
|
||||||
pixmap_priv->base.picture = picture;
|
pixmap_priv->base.picture = picture;
|
||||||
|
|
||||||
return miCreatePicture(picture);
|
return miCreatePicture(picture);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_destroy_picture(PicturePtr picture)
|
glamor_destroy_picture(PicturePtr picture)
|
||||||
{
|
{
|
||||||
PixmapPtr pixmap;
|
PixmapPtr pixmap;
|
||||||
glamor_pixmap_private *pixmap_priv;
|
glamor_pixmap_private *pixmap_priv;
|
||||||
|
|
||||||
if (!picture || !picture->pDrawable)
|
if (!picture || !picture->pDrawable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
|
pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
|
||||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||||
|
|
||||||
if (pixmap_priv) {
|
if (pixmap_priv) {
|
||||||
pixmap_priv->base.is_picture = 0;
|
pixmap_priv->base.is_picture = 0;
|
||||||
pixmap_priv->base.picture = NULL;
|
pixmap_priv->base.picture = NULL;
|
||||||
}
|
}
|
||||||
miDestroyPicture(picture);
|
miDestroyPicture(picture);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_picture_format_fixup(PicturePtr picture,
|
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
|
static Bool
|
||||||
_glamor_poly_fill_rect(DrawablePtr drawable,
|
_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 fullX1, fullX2, fullY1, fullY2;
|
||||||
int xorg, yorg;
|
int xorg, yorg;
|
||||||
int n;
|
int n;
|
||||||
register BoxPtr pbox;
|
register BoxPtr pbox;
|
||||||
RegionPtr pClip = fbGetCompositeClip(gc);
|
RegionPtr pClip = fbGetCompositeClip(gc);
|
||||||
Bool ret = FALSE;
|
Bool ret = FALSE;
|
||||||
|
|
||||||
xorg = drawable->x;
|
xorg = drawable->x;
|
||||||
yorg = drawable->y;
|
yorg = drawable->y;
|
||||||
|
|
||||||
while (nrect--) {
|
while (nrect--) {
|
||||||
fullX1 = prect->x + xorg;
|
fullX1 = prect->x + xorg;
|
||||||
fullY1 = prect->y + yorg;
|
fullY1 = prect->y + yorg;
|
||||||
fullX2 = fullX1 + (int) prect->width;
|
fullX2 = fullX1 + (int) prect->width;
|
||||||
fullY2 = fullY1 + (int) prect->height;
|
fullY2 = fullY1 + (int) prect->height;
|
||||||
|
|
||||||
n = REGION_NUM_RECTS(pClip);
|
n = REGION_NUM_RECTS(pClip);
|
||||||
pbox = REGION_RECTS(pClip);
|
pbox = REGION_RECTS(pClip);
|
||||||
/*
|
/*
|
||||||
* clip the rectangle to each box in the clip region
|
* clip the rectangle to each box in the clip region
|
||||||
* this is logically equivalent to calling Intersect(),
|
* this is logically equivalent to calling Intersect(),
|
||||||
* but rectangles may overlap each other here.
|
* but rectangles may overlap each other here.
|
||||||
*/
|
*/
|
||||||
while (n--) {
|
while (n--) {
|
||||||
int x1 = fullX1;
|
int x1 = fullX1;
|
||||||
int x2 = fullX2;
|
int x2 = fullX2;
|
||||||
int y1 = fullY1;
|
int y1 = fullY1;
|
||||||
int y2 = fullY2;
|
int y2 = fullY2;
|
||||||
|
|
||||||
if (pbox->x1 > x1)
|
if (pbox->x1 > x1)
|
||||||
x1 = pbox->x1;
|
x1 = pbox->x1;
|
||||||
if (pbox->x2 < x2)
|
if (pbox->x2 < x2)
|
||||||
x2 = pbox->x2;
|
x2 = pbox->x2;
|
||||||
if (pbox->y1 > y1)
|
if (pbox->y1 > y1)
|
||||||
y1 = pbox->y1;
|
y1 = pbox->y1;
|
||||||
if (pbox->y2 < y2)
|
if (pbox->y2 < y2)
|
||||||
y2 = pbox->y2;
|
y2 = pbox->y2;
|
||||||
|
|
||||||
pbox++;
|
pbox++;
|
||||||
if (x1 >= x2 || y1 >= y2)
|
if (x1 >= x2 || y1 >= y2)
|
||||||
continue;
|
continue;
|
||||||
if (!glamor_fill(drawable, gc, x1, y1, x2 - x1,
|
if (!glamor_fill(drawable, gc, x1, y1, x2 - x1, y2 - y1, fallback)) {
|
||||||
y2 - y1, fallback)) {
|
nrect++;
|
||||||
nrect++;
|
goto fail;
|
||||||
goto fail;
|
}
|
||||||
}
|
}
|
||||||
}
|
prect++;
|
||||||
prect++;
|
}
|
||||||
}
|
ret = TRUE;
|
||||||
ret = TRUE;
|
goto done;
|
||||||
goto done;
|
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
|
||||||
if (!fallback
|
if (!fallback && glamor_ddx_fallback_check_pixmap(drawable)
|
||||||
&& glamor_ddx_fallback_check_pixmap(drawable)
|
&& glamor_ddx_fallback_check_gc(gc))
|
||||||
&& glamor_ddx_fallback_check_gc(gc))
|
goto done;
|
||||||
goto done;
|
|
||||||
|
|
||||||
glamor_fallback(" to %p (%c)\n",
|
glamor_fallback(" to %p (%c)\n",
|
||||||
drawable, glamor_get_drawable_location(drawable));
|
drawable, glamor_get_drawable_location(drawable));
|
||||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||||
if (glamor_prepare_access_gc(gc)) {
|
if (glamor_prepare_access_gc(gc)) {
|
||||||
fbPolyFillRect(drawable, gc, nrect, prect);
|
fbPolyFillRect(drawable, gc, nrect, prect);
|
||||||
glamor_finish_access_gc(gc);
|
glamor_finish_access_gc(gc);
|
||||||
}
|
}
|
||||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
||||||
}
|
}
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_poly_fill_rect(DrawablePtr drawable,
|
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
|
Bool
|
||||||
glamor_poly_fill_rect_nf(DrawablePtr drawable,
|
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
|
static Bool
|
||||||
_glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
_glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
||||||
DDXPointPtr points, Bool fallback)
|
DDXPointPtr points, Bool fallback)
|
||||||
{
|
{
|
||||||
xRectangle *rects;
|
xRectangle *rects;
|
||||||
int x1, x2, y1, y2;
|
int x1, x2, y1, y2;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Don't try to do wide lines or non-solid fill style. */
|
/* Don't try to do wide lines or non-solid fill style. */
|
||||||
if (gc->lineWidth != 0) {
|
if (gc->lineWidth != 0) {
|
||||||
/* This ends up in miSetSpans, which is accelerated as well as we
|
/* This ends up in miSetSpans, which is accelerated as well as we
|
||||||
* can hope X wide lines will be.
|
* can hope X wide lines will be.
|
||||||
*/
|
*/
|
||||||
goto wide_line;
|
goto wide_line;
|
||||||
}
|
}
|
||||||
if (gc->lineStyle != LineSolid) {
|
if (gc->lineStyle != LineSolid) {
|
||||||
glamor_fallback
|
glamor_fallback("non-solid fill line style %d\n", gc->lineStyle);
|
||||||
("non-solid fill line style %d\n",
|
goto fail;
|
||||||
gc->lineStyle);
|
}
|
||||||
goto fail;
|
rects = malloc(sizeof(xRectangle) * (n - 1));
|
||||||
}
|
x1 = points[0].x;
|
||||||
rects = malloc(sizeof(xRectangle) * (n - 1));
|
y1 = points[0].y;
|
||||||
x1 = points[0].x;
|
/* If we have any non-horizontal/vertical, fall back. */
|
||||||
y1 = points[0].y;
|
for (i = 0; i < n - 1; i++) {
|
||||||
/* If we have any non-horizontal/vertical, fall back. */
|
if (mode == CoordModePrevious) {
|
||||||
for (i = 0; i < n - 1; i++) {
|
x2 = x1 + points[i + 1].x;
|
||||||
if (mode == CoordModePrevious) {
|
y2 = y1 + points[i + 1].y;
|
||||||
x2 = x1 + points[i + 1].x;
|
}
|
||||||
y2 = y1 + points[i + 1].y;
|
else {
|
||||||
} else {
|
x2 = points[i + 1].x;
|
||||||
x2 = points[i + 1].x;
|
y2 = points[i + 1].y;
|
||||||
y2 = points[i + 1].y;
|
}
|
||||||
}
|
if (x1 != x2 && y1 != y2) {
|
||||||
if (x1 != x2 && y1 != y2) {
|
free(rects);
|
||||||
free(rects);
|
glamor_fallback("stub diagonal poly_line\n");
|
||||||
glamor_fallback("stub diagonal poly_line\n");
|
goto fail;
|
||||||
goto fail;
|
}
|
||||||
}
|
if (x1 < x2) {
|
||||||
if (x1 < x2) {
|
rects[i].x = x1;
|
||||||
rects[i].x = x1;
|
rects[i].width = x2 - x1 + 1;
|
||||||
rects[i].width = x2 - x1 + 1;
|
}
|
||||||
} else {
|
else {
|
||||||
rects[i].x = x2;
|
rects[i].x = x2;
|
||||||
rects[i].width = x1 - x2 + 1;
|
rects[i].width = x1 - x2 + 1;
|
||||||
}
|
}
|
||||||
if (y1 < y2) {
|
if (y1 < y2) {
|
||||||
rects[i].y = y1;
|
rects[i].y = y1;
|
||||||
rects[i].height = y2 - y1 + 1;
|
rects[i].height = y2 - y1 + 1;
|
||||||
} else {
|
}
|
||||||
rects[i].y = y2;
|
else {
|
||||||
rects[i].height = y1 - y2 + 1;
|
rects[i].y = y2;
|
||||||
}
|
rects[i].height = y1 - y2 + 1;
|
||||||
|
}
|
||||||
|
|
||||||
x1 = x2;
|
x1 = x2;
|
||||||
y1 = y2;
|
y1 = y2;
|
||||||
}
|
}
|
||||||
gc->ops->PolyFillRect(drawable, gc, n - 1, rects);
|
gc->ops->PolyFillRect(drawable, gc, n - 1, rects);
|
||||||
free(rects);
|
free(rects);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
if (!fallback
|
if (!fallback && glamor_ddx_fallback_check_pixmap(drawable)
|
||||||
&& glamor_ddx_fallback_check_pixmap(drawable)
|
&& glamor_ddx_fallback_check_gc(gc))
|
||||||
&& glamor_ddx_fallback_check_gc(gc))
|
return FALSE;
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (gc->lineWidth == 0) {
|
if (gc->lineWidth == 0) {
|
||||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||||
if (glamor_prepare_access_gc(gc)) {
|
if (glamor_prepare_access_gc(gc)) {
|
||||||
fbPolyLine(drawable, gc, mode, n, points);
|
fbPolyLine(drawable, gc, mode, n, points);
|
||||||
glamor_finish_access_gc(gc);
|
glamor_finish_access_gc(gc);
|
||||||
}
|
}
|
||||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
wide_line:
|
else {
|
||||||
/* fb calls mi functions in the lineWidth != 0 case. */
|
wide_line:
|
||||||
fbPolyLine(drawable, gc, mode, n, points);
|
/* fb calls mi functions in the lineWidth != 0 case. */
|
||||||
}
|
fbPolyLine(drawable, gc, mode, n, points);
|
||||||
return TRUE;
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
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
|
Bool
|
||||||
glamor_poly_lines_nf(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
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
|
static Bool
|
||||||
_glamor_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
_glamor_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
||||||
DDXPointPtr ppt, Bool fallback)
|
DDXPointPtr ppt, Bool fallback)
|
||||||
{
|
{
|
||||||
if (!fallback
|
if (!fallback && glamor_ddx_fallback_check_gc(pGC)
|
||||||
&& glamor_ddx_fallback_check_gc(pGC)
|
&& glamor_ddx_fallback_check_pixmap(pDrawable))
|
||||||
&& glamor_ddx_fallback_check_pixmap(pDrawable))
|
return FALSE;
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
miPolyPoint(pDrawable, pGC, mode, npt, ppt);
|
miPolyPoint(pDrawable, pGC, mode, npt, ppt);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
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
|
Bool
|
||||||
glamor_poly_point_nf(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
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
|
static Bool
|
||||||
_glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
|
_glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
|
||||||
xSegment *pSeg, Bool fallback)
|
xSegment *pSeg, Bool fallback)
|
||||||
{
|
{
|
||||||
if (!fallback
|
if (!fallback && glamor_ddx_fallback_check_gc(pGC)
|
||||||
&& glamor_ddx_fallback_check_gc(pGC)
|
&& glamor_ddx_fallback_check_pixmap(pDrawable))
|
||||||
&& glamor_ddx_fallback_check_pixmap(pDrawable))
|
return FALSE;
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
miPolySegment(pDrawable, pGC, nseg, pSeg);
|
miPolySegment(pDrawable, pGC, nseg, pSeg);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
|
glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pSeg)
|
||||||
xSegment *pSeg)
|
|
||||||
{
|
{
|
||||||
_glamor_poly_segment(pDrawable, pGC, nseg, pSeg, TRUE);
|
_glamor_poly_segment(pDrawable, pGC, nseg, pSeg, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
glamor_poly_segment_nf(DrawablePtr pDrawable, GCPtr pGC, int nseg,
|
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
|
/** @file glamor_putaimge.c
|
||||||
*
|
*
|
||||||
* XPutImage implementation
|
* XPutImage implementation
|
||||||
|
@ -37,54 +36,61 @@ void
|
||||||
glamor_init_putimage_shaders(ScreenPtr screen)
|
glamor_init_putimage_shaders(ScreenPtr screen)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
glamor_screen_private *glamor_priv =
|
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||||
glamor_get_screen_private(screen);
|
const char *xybitmap_vs =
|
||||||
const char *xybitmap_vs =
|
"uniform float x_bias;\n"
|
||||||
"uniform float x_bias;\n" "uniform float x_scale;\n"
|
"uniform float x_scale;\n"
|
||||||
"uniform float y_bias;\n" "uniform float y_scale;\n"
|
"uniform float y_bias;\n"
|
||||||
"varying vec2 bitmap_coords;\n" "void main()\n" "{\n"
|
"uniform float y_scale;\n"
|
||||||
" gl_Position = vec4((gl_Vertex.x + x_bias) * x_scale,\n"
|
"varying vec2 bitmap_coords;\n"
|
||||||
" (gl_Vertex.y + y_bias) * y_scale,\n"
|
"void main()\n"
|
||||||
" 0,\n"
|
"{\n"
|
||||||
" 1);\n"
|
" gl_Position = vec4((gl_Vertex.x + x_bias) * x_scale,\n"
|
||||||
" bitmap_coords = gl_MultiTexCoord0.xy;\n" "}\n";
|
" (gl_Vertex.y + y_bias) * y_scale,\n"
|
||||||
const char *xybitmap_fs =
|
" 0,\n"
|
||||||
"uniform vec4 fg, bg;\n" "varying vec2 bitmap_coords;\n"
|
" 1);\n"
|
||||||
"uniform sampler2D bitmap_sampler;\n" "void main()\n" "{\n"
|
" bitmap_coords = gl_MultiTexCoord0.xy;\n"
|
||||||
" float bitmap_value = texture2D(bitmap_sampler,\n"
|
"}\n";
|
||||||
" bitmap_coords).x;\n"
|
const char *xybitmap_fs =
|
||||||
" gl_FragColor = mix(bg, fg, bitmap_value);\n" "}\n";
|
"uniform vec4 fg, bg;\n"
|
||||||
GLint fs_prog, vs_prog, prog;
|
"varying vec2 bitmap_coords;\n"
|
||||||
GLint sampler_uniform_location;
|
"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)
|
if (!GLEW_ARB_fragment_shader)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
prog = dispatch->glCreateProgram();
|
prog = dispatch->glCreateProgram();
|
||||||
vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, xybitmap_vs);
|
vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, xybitmap_vs);
|
||||||
fs_prog =
|
fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, xybitmap_fs);
|
||||||
glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, xybitmap_fs);
|
dispatch->glAttachShader(prog, vs_prog);
|
||||||
dispatch->glAttachShader(prog, vs_prog);
|
dispatch->glAttachShader(prog, fs_prog);
|
||||||
dispatch->glAttachShader(prog, fs_prog);
|
glamor_link_glsl_prog(prog);
|
||||||
glamor_link_glsl_prog(prog);
|
|
||||||
|
|
||||||
dispatch->glUseProgram(prog);
|
dispatch->glUseProgram(prog);
|
||||||
sampler_uniform_location =
|
sampler_uniform_location =
|
||||||
dispatch->glGetUniformLocation(prog, "bitmap_sampler");
|
dispatch->glGetUniformLocation(prog, "bitmap_sampler");
|
||||||
dispatch->glUniform1i(sampler_uniform_location, 0);
|
dispatch->glUniform1i(sampler_uniform_location, 0);
|
||||||
|
|
||||||
glamor_priv->put_image_xybitmap_fg_uniform_location =
|
glamor_priv->put_image_xybitmap_fg_uniform_location =
|
||||||
dispatch->glGetUniformLocation(prog, "fg");
|
dispatch->glGetUniformLocation(prog, "fg");
|
||||||
glamor_priv->put_image_xybitmap_bg_uniform_location =
|
glamor_priv->put_image_xybitmap_bg_uniform_location =
|
||||||
dispatch->glGetUniformLocation(prog, "bg");
|
dispatch->glGetUniformLocation(prog, "bg");
|
||||||
glamor_get_transform_uniform_locations(prog,
|
glamor_get_transform_uniform_locations(prog,
|
||||||
&glamor_priv->put_image_xybitmap_transform);
|
&glamor_priv->
|
||||||
glamor_priv->put_image_xybitmap_prog = prog;
|
put_image_xybitmap_transform);
|
||||||
dispatch->glUseProgram(0);
|
glamor_priv->put_image_xybitmap_prog = prog;
|
||||||
|
dispatch->glUseProgram(0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Do an XYBitmap putimage. The bits are byte-aligned rows of bitmap
|
/* 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
|
* 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
|
* 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
|
static int
|
||||||
y_flip(PixmapPtr pixmap, int y)
|
y_flip(PixmapPtr pixmap, int y)
|
||||||
{
|
{
|
||||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||||
PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
|
PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
|
||||||
|
|
||||||
if (pixmap == screen_pixmap)
|
if (pixmap == screen_pixmap)
|
||||||
return (pixmap->drawable.height - 1) - y;
|
return (pixmap->drawable.height - 1) - y;
|
||||||
else
|
else
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
||||||
int x, int y, int w, int h, int left_pad,
|
int x, int y, int w, int h, int left_pad,
|
||||||
int image_format, char *bits)
|
int image_format, char *bits)
|
||||||
{
|
{
|
||||||
ScreenPtr screen = drawable->pScreen;
|
ScreenPtr screen = drawable->pScreen;
|
||||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||||
glamor_screen_private *glamor_priv =
|
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||||
glamor_get_screen_private(screen);
|
float fg[4], bg[4];
|
||||||
float fg[4], bg[4];
|
GLuint tex;
|
||||||
GLuint tex;
|
unsigned int stride = PixmapBytePad(1, w + left_pad);
|
||||||
unsigned int stride = PixmapBytePad(1, w + left_pad);
|
RegionPtr clip;
|
||||||
RegionPtr clip;
|
BoxPtr box;
|
||||||
BoxPtr box;
|
int nbox;
|
||||||
int nbox;
|
float dest_coords[8];
|
||||||
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;
|
|
||||||
|
|
||||||
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,
|
pixmap_priv_get_scale(pixmap_priv, &xscale, &yscale);
|
||||||
x, y,
|
|
||||||
x + w, y + h,
|
|
||||||
glamor_priv->yInverted, dest_coords);
|
|
||||||
|
|
||||||
glamor_fallback("glamor_put_image_xybitmap: disabled\n");
|
glamor_set_normalize_vcoords(xscale, yscale,
|
||||||
goto fail;
|
x, y,
|
||||||
|
x + w, y + h,
|
||||||
|
glamor_priv->yInverted, dest_coords);
|
||||||
|
|
||||||
if (glamor_priv->put_image_xybitmap_prog == 0) {
|
glamor_fallback("glamor_put_image_xybitmap: disabled\n");
|
||||||
ErrorF("no program for xybitmap putimage\n");
|
goto fail;
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
glamor_set_alu(gc->alu);
|
if (glamor_priv->put_image_xybitmap_prog == 0) {
|
||||||
if (!glamor_set_planemask(pixmap, gc->planemask))
|
ErrorF("no program for xybitmap putimage\n");
|
||||||
goto fail;
|
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->glUseProgram(glamor_priv->put_image_xybitmap_prog);
|
||||||
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->glGenTextures(1, &tex);
|
glamor_get_color_4f_from_pixel(pixmap, gc->fgPixel, fg);
|
||||||
dispatch->glActiveTexture(GL_TEXTURE0);
|
dispatch->glUniform4fv
|
||||||
dispatch->glEnable(GL_TEXTURE_2D);
|
(glamor_priv->put_image_xybitmap_fg_uniform_location, 1, fg);
|
||||||
dispatch->glBindTexture(GL_TEXTURE_2D, tex);
|
glamor_get_color_4f_from_pixel(pixmap, gc->bgPixel, bg);
|
||||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
dispatch->glUniform4fv
|
||||||
GL_NEAREST);
|
(glamor_priv->put_image_xybitmap_bg_uniform_location, 1, bg);
|
||||||
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);
|
|
||||||
|
|
||||||
/* Now that we've set up our bitmap texture and the shader, shove
|
dispatch->glGenTextures(1, &tex);
|
||||||
* the destination rectangle through the cliprects and run the
|
dispatch->glActiveTexture(GL_TEXTURE0);
|
||||||
* shader on the resulting fragments.
|
dispatch->glEnable(GL_TEXTURE_2D);
|
||||||
*/
|
dispatch->glBindTexture(GL_TEXTURE_2D, tex);
|
||||||
dispatch->glVertexPointer(2, GL_FLOAT, 0, dest_coords);
|
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
dispatch->glEnableClientState(GL_VERTEX_ARRAY);
|
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
dispatch->glClientActiveTexture(GL_TEXTURE0);
|
dispatch->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
dispatch->glTexCoordPointer(2, GL_FLOAT, 0, bitmap_coords);
|
dispatch->glPixelStorei(GL_UNPACK_ROW_LENGTH, stride * 8);
|
||||||
dispatch->glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
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);
|
/* Now that we've set up our bitmap texture and the shader, shove
|
||||||
clip = fbGetCompositeClip(gc);
|
* the destination rectangle through the cliprects and run the
|
||||||
for (nbox = REGION_NUM_RECTS(clip),
|
* shader on the resulting fragments.
|
||||||
box = REGION_RECTS(clip); nbox--; box++) {
|
*/
|
||||||
int x1 = x;
|
dispatch->glVertexPointer(2, GL_FLOAT, 0, dest_coords);
|
||||||
int y1 = y;
|
dispatch->glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
int x2 = x + w;
|
dispatch->glClientActiveTexture(GL_TEXTURE0);
|
||||||
int y2 = y + h;
|
dispatch->glTexCoordPointer(2, GL_FLOAT, 0, bitmap_coords);
|
||||||
|
dispatch->glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
|
||||||
if (x1 < box->x1)
|
dispatch->glEnable(GL_SCISSOR_TEST);
|
||||||
x1 = box->x1;
|
clip = fbGetCompositeClip(gc);
|
||||||
if (y1 < box->y1)
|
for (nbox = REGION_NUM_RECTS(clip), box = REGION_RECTS(clip); nbox--; box++) {
|
||||||
y1 = box->y1;
|
int x1 = x;
|
||||||
if (x2 > box->x2)
|
int y1 = y;
|
||||||
x2 = box->x2;
|
int x2 = x + w;
|
||||||
if (y2 > box->y2)
|
int y2 = y + h;
|
||||||
y2 = box->y2;
|
|
||||||
if (x1 >= x2 || y1 >= y2)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
dispatch->glScissor(box->x1,
|
if (x1 < box->x1)
|
||||||
y_flip(pixmap, box->y1),
|
x1 = box->x1;
|
||||||
box->x2 - box->x1, box->y2 - box->y1);
|
if (y1 < box->y1)
|
||||||
dispatch->glDrawArrays(GL_QUADS, 0, 4);
|
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);
|
dispatch->glScissor(box->x1,
|
||||||
glamor_set_alu(GXcopy);
|
y_flip(pixmap, box->y1),
|
||||||
glamor_set_planemask(pixmap, ~0);
|
box->x2 - box->x1, box->y2 - box->y1);
|
||||||
dispatch->glDeleteTextures(1, &tex);
|
dispatch->glDrawArrays(GL_QUADS, 0, 4);
|
||||||
dispatch->glDisable(GL_TEXTURE_2D);
|
}
|
||||||
dispatch->glDisableClientState(GL_VERTEX_ARRAY);
|
|
||||||
dispatch->glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
dispatch->glDisable(GL_SCISSOR_TEST);
|
||||||
return;
|
glamor_set_alu(GXcopy);
|
||||||
glamor_set_alu(GXcopy);
|
glamor_set_planemask(pixmap, ~0);
|
||||||
glamor_set_planemask(pixmap, ~0);
|
dispatch->glDeleteTextures(1, &tex);
|
||||||
glamor_fallback(": to %p (%c)\n",
|
dispatch->glDisable(GL_TEXTURE_2D);
|
||||||
drawable, glamor_get_drawable_location(drawable));
|
dispatch->glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
fail:
|
dispatch->glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
return;
|
||||||
fbPutImage(drawable, gc, 1, x, y, w, h, left_pad, XYBitmap,
|
glamor_set_alu(GXcopy);
|
||||||
bits);
|
glamor_set_planemask(pixmap, ~0);
|
||||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
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
|
#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,
|
_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);
|
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||||
glamor_pixmap_private *pixmap_priv =
|
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||||
glamor_get_pixmap_private(pixmap);
|
RegionPtr clip;
|
||||||
RegionPtr clip;
|
int x_off, y_off;
|
||||||
int x_off, y_off;
|
Bool ret = FALSE;
|
||||||
Bool ret = FALSE;
|
PixmapPtr temp_pixmap, sub_pixmap;
|
||||||
PixmapPtr temp_pixmap, sub_pixmap;
|
glamor_pixmap_private *temp_pixmap_priv;
|
||||||
glamor_pixmap_private *temp_pixmap_priv;
|
BoxRec box;
|
||||||
BoxRec box;
|
|
||||||
|
|
||||||
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
|
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
|
||||||
clip = fbGetCompositeClip(gc);
|
clip = fbGetCompositeClip(gc);
|
||||||
if (image_format == XYBitmap) {
|
if (image_format == XYBitmap) {
|
||||||
assert(depth == 1);
|
assert(depth == 1);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
|
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
|
||||||
glamor_fallback("has no fbo.\n");
|
glamor_fallback("has no fbo.\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (image_format != ZPixmap) {
|
if (image_format != ZPixmap) {
|
||||||
glamor_fallback("non-ZPixmap\n");
|
glamor_fallback("non-ZPixmap\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!glamor_set_planemask(pixmap, gc->planemask)) {
|
if (!glamor_set_planemask(pixmap, gc->planemask)) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
/* create a temporary pixmap and upload the bits to that
|
/* create a temporary pixmap and upload the bits to that
|
||||||
* pixmap, then apply clip copy it to the destination pixmap.*/
|
* pixmap, then apply clip copy it to the destination pixmap.*/
|
||||||
box.x1 = x + drawable->x;
|
box.x1 = x + drawable->x;
|
||||||
box.y1 = y + drawable->y;
|
box.y1 = y + drawable->y;
|
||||||
box.x2 = x + w + drawable->x;
|
box.x2 = x + w + drawable->x;
|
||||||
box.y2 = y + h + drawable->y;
|
box.y2 = y + h + drawable->y;
|
||||||
|
|
||||||
if ((clip != NULL && RegionContainsRect(clip, &box) != rgnIN)
|
if ((clip != NULL && RegionContainsRect(clip, &box) != rgnIN)
|
||||||
|| gc->alu != GXcopy) {
|
|| gc->alu != GXcopy) {
|
||||||
temp_pixmap = glamor_create_pixmap(drawable->pScreen, w, h, depth, 0);
|
temp_pixmap = glamor_create_pixmap(drawable->pScreen, w, h, depth, 0);
|
||||||
if (temp_pixmap == NULL)
|
if (temp_pixmap == NULL)
|
||||||
goto fail;
|
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)) {
|
if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv)) {
|
||||||
temp_pixmap_priv->base.picture = pixmap_priv->base.picture;
|
temp_pixmap_priv->base.picture = pixmap_priv->base.picture;
|
||||||
temp_pixmap_priv->base.is_picture = pixmap_priv->base.is_picture;
|
temp_pixmap_priv->base.is_picture = pixmap_priv->base.is_picture;
|
||||||
}
|
}
|
||||||
|
|
||||||
glamor_upload_sub_pixmap_to_texture(temp_pixmap, 0, 0, w, h,
|
glamor_upload_sub_pixmap_to_texture(temp_pixmap, 0, 0, w, h,
|
||||||
pixmap->devKind, bits, 0);
|
pixmap->devKind, bits, 0);
|
||||||
|
|
||||||
glamor_copy_area(&temp_pixmap->drawable, drawable, gc, 0, 0, w, h, x, y);
|
glamor_copy_area(&temp_pixmap->drawable, drawable, gc, 0, 0, w, h, x,
|
||||||
glamor_destroy_pixmap(temp_pixmap);
|
y);
|
||||||
} else
|
glamor_destroy_pixmap(temp_pixmap);
|
||||||
glamor_upload_sub_pixmap_to_texture(pixmap, x + drawable->x + x_off, y + drawable->y + y_off,
|
}
|
||||||
w, h, PixmapBytePad(w, depth), bits, 0);
|
else
|
||||||
ret = TRUE;
|
glamor_upload_sub_pixmap_to_texture(pixmap, x + drawable->x + x_off,
|
||||||
goto done;
|
y + drawable->y + y_off, w, h,
|
||||||
|
PixmapBytePad(w, depth), bits, 0);
|
||||||
|
ret = TRUE;
|
||||||
|
goto done;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
glamor_set_planemask(pixmap, ~0);
|
glamor_set_planemask(pixmap, ~0);
|
||||||
|
|
||||||
if (!fallback
|
if (!fallback && glamor_ddx_fallback_check_pixmap(&pixmap->drawable))
|
||||||
&& glamor_ddx_fallback_check_pixmap(&pixmap->drawable))
|
goto done;
|
||||||
goto done;
|
|
||||||
|
|
||||||
glamor_fallback("to %p (%c)\n",
|
glamor_fallback("to %p (%c)\n",
|
||||||
drawable, glamor_get_drawable_location(drawable));
|
drawable, glamor_get_drawable_location(drawable));
|
||||||
|
|
||||||
sub_pixmap = glamor_get_sub_pixmap(pixmap, x + x_off + drawable->x,
|
sub_pixmap = glamor_get_sub_pixmap(pixmap, x + x_off + drawable->x,
|
||||||
y + y_off + drawable->y, w, h,
|
y + y_off + drawable->y, w, h,
|
||||||
GLAMOR_ACCESS_RW);
|
GLAMOR_ACCESS_RW);
|
||||||
if (sub_pixmap) {
|
if (sub_pixmap) {
|
||||||
if (clip != NULL)
|
if (clip != NULL)
|
||||||
pixman_region_translate (clip, -x - drawable->x, -y - drawable->y);
|
pixman_region_translate(clip, -x - drawable->x, -y - drawable->y);
|
||||||
|
|
||||||
fbPutImage(&sub_pixmap->drawable, gc, depth, 0, 0, w, h,
|
fbPutImage(&sub_pixmap->drawable, gc, depth, 0, 0, w, h,
|
||||||
left_pad, image_format, bits);
|
left_pad, image_format, bits);
|
||||||
|
|
||||||
glamor_put_sub_pixmap(sub_pixmap, pixmap,
|
glamor_put_sub_pixmap(sub_pixmap, pixmap,
|
||||||
x + x_off + drawable->x,
|
x + x_off + drawable->x,
|
||||||
y + y_off + drawable->y,
|
y + y_off + drawable->y, w, h, GLAMOR_ACCESS_RW);
|
||||||
w, h, GLAMOR_ACCESS_RW);
|
if (clip != NULL)
|
||||||
if (clip != NULL)
|
pixman_region_translate(clip, x + drawable->x, y + drawable->y);
|
||||||
pixman_region_translate (clip, x + drawable->x, y + drawable->y);
|
}
|
||||||
} else
|
else
|
||||||
fbPutImage(drawable, gc, depth, x, y, w, h,
|
fbPutImage(drawable, gc, depth, x, y, w, h,
|
||||||
left_pad, image_format, bits);
|
left_pad, image_format, bits);
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
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,
|
_glamor_put_image(drawable, gc, depth, x, y, w, h,
|
||||||
left_pad, image_format, bits, TRUE);
|
left_pad, image_format, bits, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
glamor_put_image_nf(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
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,
|
return _glamor_put_image(drawable, gc, depth, x, y, w, h,
|
||||||
left_pad, image_format, bits, FALSE);
|
left_pad, image_format, bits, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -30,82 +30,83 @@
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
_glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
_glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
||||||
DDXPointPtr points, int *widths, int numPoints, int sorted,
|
DDXPointPtr points, int *widths, int numPoints, int sorted,
|
||||||
Bool fallback)
|
Bool fallback)
|
||||||
{
|
{
|
||||||
PixmapPtr dest_pixmap = glamor_get_drawable_pixmap(drawable);
|
PixmapPtr dest_pixmap = glamor_get_drawable_pixmap(drawable);
|
||||||
glamor_pixmap_private *dest_pixmap_priv;
|
glamor_pixmap_private *dest_pixmap_priv;
|
||||||
int i;
|
int i;
|
||||||
uint8_t *drawpixels_src = (uint8_t *) src;
|
uint8_t *drawpixels_src = (uint8_t *) src;
|
||||||
RegionPtr clip = fbGetCompositeClip(gc);
|
RegionPtr clip = fbGetCompositeClip(gc);
|
||||||
BoxRec *pbox;
|
BoxRec *pbox;
|
||||||
int x_off, y_off;
|
int x_off, y_off;
|
||||||
Bool ret = FALSE;
|
Bool ret = FALSE;
|
||||||
|
|
||||||
dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap);
|
dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap);
|
||||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dest_pixmap_priv)) {
|
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dest_pixmap_priv)) {
|
||||||
glamor_fallback("pixmap has no fbo.\n");
|
glamor_fallback("pixmap has no fbo.\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX Shall we set alu here? */
|
/* XXX Shall we set alu here? */
|
||||||
if (!glamor_set_planemask(dest_pixmap, gc->planemask))
|
if (!glamor_set_planemask(dest_pixmap, gc->planemask))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
glamor_get_drawable_deltas(drawable, dest_pixmap, &x_off, &y_off);
|
glamor_get_drawable_deltas(drawable, dest_pixmap, &x_off, &y_off);
|
||||||
for (i = 0; i < numPoints; i++) {
|
for (i = 0; i < numPoints; i++) {
|
||||||
|
|
||||||
int n = REGION_NUM_RECTS(clip);
|
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;
|
|
||||||
|
|
||||||
if (pbox->y1 > points[i].y || pbox->y2 < points[i].y)
|
pbox = REGION_RECTS(clip);
|
||||||
break;
|
while (n--) {
|
||||||
x1 = x1 > pbox->x1 ? x1 : pbox->x1;
|
int x1 = points[i].x;
|
||||||
x2 = x2 < pbox->x2 ? x2 : pbox->x2;
|
int x2 = x1 + widths[i];
|
||||||
if (x1 >= x2)
|
int y1 = points[i].y;
|
||||||
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;
|
|
||||||
|
|
||||||
fail:
|
if (pbox->y1 > points[i].y || pbox->y2 < points[i].y)
|
||||||
if (!fallback
|
break;
|
||||||
&& glamor_ddx_fallback_check_pixmap(drawable))
|
x1 = x1 > pbox->x1 ? x1 : pbox->x1;
|
||||||
goto done;
|
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",
|
fail:
|
||||||
drawable, glamor_get_drawable_location(drawable));
|
if (!fallback && glamor_ddx_fallback_check_pixmap(drawable))
|
||||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
goto done;
|
||||||
fbSetSpans(drawable, gc, src, points, widths, numPoints, sorted);
|
|
||||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
|
||||||
}
|
|
||||||
ret = TRUE;
|
|
||||||
|
|
||||||
done:
|
glamor_fallback("to %p (%c)\n",
|
||||||
return ret;
|
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
|
void
|
||||||
glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
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,
|
_glamor_set_spans(drawable, gc, src, points, widths, n, sorted, TRUE);
|
||||||
widths, n, sorted, TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
glamor_set_spans_nf(DrawablePtr drawable, GCPtr gc, char *src,
|
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,
|
return _glamor_set_spans(drawable, gc, src, points,
|
||||||
widths, n, sorted, FALSE);
|
widths, n, sorted, FALSE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,290 +36,276 @@
|
||||||
void
|
void
|
||||||
glamor_init_tile_shader(ScreenPtr screen)
|
glamor_init_tile_shader(ScreenPtr screen)
|
||||||
{
|
{
|
||||||
glamor_screen_private *glamor_priv;
|
glamor_screen_private *glamor_priv;
|
||||||
glamor_gl_dispatch *dispatch;
|
glamor_gl_dispatch *dispatch;
|
||||||
const char *tile_vs =
|
const char *tile_vs =
|
||||||
"attribute vec4 v_position;\n"
|
"attribute vec4 v_position;\n"
|
||||||
"attribute vec4 v_texcoord0;\n"
|
"attribute vec4 v_texcoord0;\n"
|
||||||
"varying vec2 tile_texture;\n"
|
"varying vec2 tile_texture;\n"
|
||||||
"void main()\n"
|
"void main()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" gl_Position = v_position;\n"
|
" gl_Position = v_position;\n"
|
||||||
" tile_texture = v_texcoord0.xy;\n" "}\n";
|
" tile_texture = v_texcoord0.xy;\n"
|
||||||
const char *tile_fs =
|
"}\n";
|
||||||
GLAMOR_DEFAULT_PRECISION
|
const char *tile_fs =
|
||||||
"varying vec2 tile_texture;\n"
|
GLAMOR_DEFAULT_PRECISION
|
||||||
"uniform sampler2D sampler;\n"
|
"varying vec2 tile_texture;\n"
|
||||||
"uniform vec2 wh;"
|
"uniform sampler2D sampler;\n"
|
||||||
"void main()\n"
|
"uniform vec2 wh;"
|
||||||
"{\n"
|
"void main()\n"
|
||||||
" vec2 rel_tex;"
|
"{\n"
|
||||||
" rel_tex = tile_texture * wh; \n"
|
" vec2 rel_tex;"
|
||||||
" rel_tex = floor(rel_tex) + (fract(rel_tex) / wh); \n"
|
" rel_tex = tile_texture * wh; \n"
|
||||||
" gl_FragColor = texture2D(sampler, rel_tex);\n"
|
" rel_tex = floor(rel_tex) + (fract(rel_tex) / wh); \n"
|
||||||
"}\n";
|
" gl_FragColor = texture2D(sampler, rel_tex);\n"
|
||||||
GLint fs_prog, vs_prog;
|
"}\n";
|
||||||
GLint sampler_uniform_location;
|
GLint fs_prog, vs_prog;
|
||||||
|
GLint sampler_uniform_location;
|
||||||
|
|
||||||
glamor_priv = glamor_get_screen_private(screen);
|
glamor_priv = glamor_get_screen_private(screen);
|
||||||
dispatch = glamor_get_dispatch(glamor_priv);
|
dispatch = glamor_get_dispatch(glamor_priv);
|
||||||
glamor_priv->tile_prog = dispatch->glCreateProgram();
|
glamor_priv->tile_prog = dispatch->glCreateProgram();
|
||||||
vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, tile_vs);
|
vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, tile_vs);
|
||||||
fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
|
fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER, tile_fs);
|
||||||
tile_fs);
|
dispatch->glAttachShader(glamor_priv->tile_prog, vs_prog);
|
||||||
dispatch->glAttachShader(glamor_priv->tile_prog, vs_prog);
|
dispatch->glAttachShader(glamor_priv->tile_prog, fs_prog);
|
||||||
dispatch->glAttachShader(glamor_priv->tile_prog, fs_prog);
|
|
||||||
|
|
||||||
dispatch->glBindAttribLocation(glamor_priv->tile_prog,
|
dispatch->glBindAttribLocation(glamor_priv->tile_prog,
|
||||||
GLAMOR_VERTEX_POS, "v_position");
|
GLAMOR_VERTEX_POS, "v_position");
|
||||||
dispatch->glBindAttribLocation(glamor_priv->tile_prog,
|
dispatch->glBindAttribLocation(glamor_priv->tile_prog,
|
||||||
GLAMOR_VERTEX_SOURCE,
|
GLAMOR_VERTEX_SOURCE, "v_texcoord0");
|
||||||
"v_texcoord0");
|
glamor_link_glsl_prog(dispatch, glamor_priv->tile_prog);
|
||||||
glamor_link_glsl_prog(dispatch, glamor_priv->tile_prog);
|
|
||||||
|
|
||||||
sampler_uniform_location =
|
sampler_uniform_location =
|
||||||
dispatch->glGetUniformLocation(glamor_priv->tile_prog,
|
dispatch->glGetUniformLocation(glamor_priv->tile_prog, "sampler");
|
||||||
"sampler");
|
dispatch->glUseProgram(glamor_priv->tile_prog);
|
||||||
dispatch->glUseProgram(glamor_priv->tile_prog);
|
dispatch->glUniform1i(sampler_uniform_location, 0);
|
||||||
dispatch->glUniform1i(sampler_uniform_location, 0);
|
|
||||||
|
|
||||||
glamor_priv->tile_wh =
|
glamor_priv->tile_wh =
|
||||||
dispatch->glGetUniformLocation(glamor_priv->tile_prog,
|
dispatch->glGetUniformLocation(glamor_priv->tile_prog, "wh");
|
||||||
"wh");
|
dispatch->glUseProgram(0);
|
||||||
dispatch->glUseProgram(0);
|
glamor_put_dispatch(glamor_priv);
|
||||||
glamor_put_dispatch(glamor_priv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_fini_tile_shader(ScreenPtr screen)
|
glamor_fini_tile_shader(ScreenPtr screen)
|
||||||
{
|
{
|
||||||
glamor_screen_private *glamor_priv;
|
glamor_screen_private *glamor_priv;
|
||||||
glamor_gl_dispatch *dispatch;
|
glamor_gl_dispatch *dispatch;
|
||||||
|
|
||||||
glamor_priv = glamor_get_screen_private(screen);
|
glamor_priv = glamor_get_screen_private(screen);
|
||||||
dispatch = glamor_get_dispatch(glamor_priv);
|
dispatch = glamor_get_dispatch(glamor_priv);
|
||||||
dispatch->glDeleteProgram(glamor_priv->tile_prog);
|
dispatch->glDeleteProgram(glamor_priv->tile_prog);
|
||||||
glamor_put_dispatch(glamor_priv);
|
glamor_put_dispatch(glamor_priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
_glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
||||||
int x, int y, int width, int height,
|
int x, int y, int width, int height, int tile_x, int tile_y)
|
||||||
int tile_x, int tile_y)
|
|
||||||
{
|
{
|
||||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||||
glamor_screen_private *glamor_priv =
|
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||||
glamor_get_screen_private(screen);
|
glamor_gl_dispatch *dispatch;
|
||||||
glamor_gl_dispatch *dispatch;
|
int x1 = x;
|
||||||
int x1 = x;
|
int x2 = x + width;
|
||||||
int x2 = x + width;
|
int y1 = y;
|
||||||
int y1 = y;
|
int y2 = y + height;
|
||||||
int y2 = y + height;
|
int tile_x1 = tile_x;
|
||||||
int tile_x1 = tile_x;
|
int tile_x2 = tile_x + width;
|
||||||
int tile_x2 = tile_x + width;
|
int tile_y1 = tile_y;
|
||||||
int tile_y1 = tile_y;
|
int tile_y2 = tile_y + height;
|
||||||
int tile_y2 = tile_y + height;
|
float vertices[8];
|
||||||
float vertices[8];
|
float source_texcoords[8];
|
||||||
float source_texcoords[8];
|
GLfloat dst_xscale, dst_yscale, src_xscale, src_yscale;
|
||||||
GLfloat dst_xscale, dst_yscale, src_xscale, src_yscale;
|
glamor_pixmap_private *src_pixmap_priv;
|
||||||
glamor_pixmap_private *src_pixmap_priv;
|
glamor_pixmap_private *dst_pixmap_priv;
|
||||||
glamor_pixmap_private *dst_pixmap_priv;
|
float wh[4];
|
||||||
float wh[4];
|
|
||||||
src_pixmap_priv = glamor_get_pixmap_private(tile);
|
|
||||||
dst_pixmap_priv = glamor_get_pixmap_private(pixmap);
|
|
||||||
|
|
||||||
glamor_set_destination_pixmap_priv_nc(dst_pixmap_priv);
|
src_pixmap_priv = glamor_get_pixmap_private(tile);
|
||||||
pixmap_priv_get_dest_scale(dst_pixmap_priv, &dst_xscale, &dst_yscale);
|
dst_pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||||
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);
|
glamor_set_destination_pixmap_priv_nc(dst_pixmap_priv);
|
||||||
dispatch->glUniform2fv(glamor_priv->tile_wh, 1, wh);
|
pixmap_priv_get_dest_scale(dst_pixmap_priv, &dst_xscale, &dst_yscale);
|
||||||
dispatch->glActiveTexture(GL_TEXTURE0);
|
pixmap_priv_get_scale(src_pixmap_priv, &src_xscale, &src_yscale);
|
||||||
dispatch->glBindTexture(GL_TEXTURE_2D,
|
dispatch = glamor_get_dispatch(glamor_priv);
|
||||||
src_pixmap_priv->base.fbo->tex);
|
dispatch->glUseProgram(glamor_priv->tile_prog);
|
||||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
|
||||||
GL_TEXTURE_MIN_FILTER,
|
glamor_pixmap_fbo_fix_wh_ratio(wh, src_pixmap_priv);
|
||||||
GL_NEAREST);
|
dispatch->glUniform2fv(glamor_priv->tile_wh, 1, wh);
|
||||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
dispatch->glActiveTexture(GL_TEXTURE0);
|
||||||
GL_TEXTURE_MAG_FILTER,
|
dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv->base.fbo->tex);
|
||||||
GL_NEAREST);
|
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
|
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
GL_REPEAT);
|
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
|
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
GL_REPEAT);
|
|
||||||
#ifndef GLAMOR_GLES2
|
#ifndef GLAMOR_GLES2
|
||||||
dispatch->glEnable(GL_TEXTURE_2D);
|
dispatch->glEnable(GL_TEXTURE_2D);
|
||||||
#endif
|
#endif
|
||||||
glamor_set_repeat_normalize_tcoords
|
glamor_set_repeat_normalize_tcoords
|
||||||
(src_pixmap_priv, RepeatNormal,
|
(src_pixmap_priv, RepeatNormal,
|
||||||
src_xscale, src_yscale,
|
src_xscale, src_yscale,
|
||||||
tile_x1, tile_y1,
|
tile_x1, tile_y1,
|
||||||
tile_x2, tile_y2,
|
tile_x2, tile_y2, glamor_priv->yInverted, source_texcoords);
|
||||||
glamor_priv->yInverted,
|
|
||||||
source_texcoords);
|
|
||||||
|
|
||||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
|
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
|
||||||
GL_FLOAT, GL_FALSE,
|
GL_FLOAT, GL_FALSE,
|
||||||
2 * sizeof(float),
|
2 * sizeof(float), source_texcoords);
|
||||||
source_texcoords);
|
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
|
||||||
|
|
||||||
glamor_set_normalize_vcoords(dst_pixmap_priv, dst_xscale, dst_yscale,
|
glamor_set_normalize_vcoords(dst_pixmap_priv, dst_xscale, dst_yscale,
|
||||||
x1, y1,
|
x1, y1,
|
||||||
x2, y2,
|
x2, y2, glamor_priv->yInverted, vertices);
|
||||||
glamor_priv->yInverted, vertices);
|
|
||||||
|
|
||||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||||
GL_FALSE, 2 * sizeof(float),
|
GL_FALSE, 2 * sizeof(float), vertices);
|
||||||
vertices);
|
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||||
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
|
||||||
|
|
||||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||||
#ifndef GLAMOR_GLES2
|
#ifndef GLAMOR_GLES2
|
||||||
dispatch->glDisable(GL_TEXTURE_2D);
|
dispatch->glDisable(GL_TEXTURE_2D);
|
||||||
#endif
|
#endif
|
||||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||||
dispatch->glUseProgram(0);
|
dispatch->glUseProgram(0);
|
||||||
glamor_put_dispatch(glamor_priv);
|
glamor_put_dispatch(glamor_priv);
|
||||||
|
|
||||||
glamor_priv->state = RENDER_STATE;
|
glamor_priv->state = RENDER_STATE;
|
||||||
glamor_priv->render_idle_cnt = 0;
|
glamor_priv->render_idle_cnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
||||||
int x, int y, int width, int height,
|
int x, int y, int width, int height,
|
||||||
unsigned char alu, unsigned long planemask,
|
unsigned char alu, unsigned long planemask, int tile_x, int tile_y)
|
||||||
int tile_x, int tile_y)
|
|
||||||
{
|
{
|
||||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||||
glamor_screen_private *glamor_priv =
|
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||||
glamor_get_screen_private(screen);
|
glamor_pixmap_private *dst_pixmap_priv;
|
||||||
glamor_pixmap_private *dst_pixmap_priv;
|
glamor_pixmap_private *src_pixmap_priv;
|
||||||
glamor_pixmap_private *src_pixmap_priv;
|
glamor_gl_dispatch *dispatch;
|
||||||
glamor_gl_dispatch *dispatch;
|
|
||||||
|
|
||||||
dst_pixmap_priv = glamor_get_pixmap_private(pixmap);
|
dst_pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||||
src_pixmap_priv = glamor_get_pixmap_private(tile);
|
src_pixmap_priv = glamor_get_pixmap_private(tile);
|
||||||
|
|
||||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dst_pixmap_priv))
|
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dst_pixmap_priv))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (glamor_priv->tile_prog == 0) {
|
if (glamor_priv->tile_prog == 0) {
|
||||||
glamor_fallback("Tiling unsupported\n");
|
glamor_fallback("Tiling unsupported\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(src_pixmap_priv)) {
|
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(src_pixmap_priv)) {
|
||||||
/* XXX dynamic uploading candidate. */
|
/* XXX dynamic uploading candidate. */
|
||||||
glamor_fallback("Non-texture tile pixmap\n");
|
glamor_fallback("Non-texture tile pixmap\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!glamor_set_planemask(pixmap, planemask)) {
|
if (!glamor_set_planemask(pixmap, planemask)) {
|
||||||
glamor_fallback("unsupported planemask %lx\n", planemask);
|
glamor_fallback("unsupported planemask %lx\n", planemask);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch = glamor_get_dispatch(glamor_priv);
|
dispatch = glamor_get_dispatch(glamor_priv);
|
||||||
if (!glamor_set_alu(dispatch, alu)) {
|
if (!glamor_set_alu(dispatch, alu)) {
|
||||||
glamor_fallback("unsupported alu %x\n", alu);
|
glamor_fallback("unsupported alu %x\n", alu);
|
||||||
glamor_put_dispatch(glamor_priv);
|
glamor_put_dispatch(glamor_priv);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dst_pixmap_priv->type == GLAMOR_TEXTURE_LARGE
|
if (dst_pixmap_priv->type == GLAMOR_TEXTURE_LARGE
|
||||||
|| src_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
|| src_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||||
glamor_pixmap_clipped_regions *clipped_dst_regions;
|
glamor_pixmap_clipped_regions *clipped_dst_regions;
|
||||||
int n_dst_region, i, j, k;
|
int n_dst_region, i, j, k;
|
||||||
BoxRec box;
|
BoxRec box;
|
||||||
RegionRec region;
|
RegionRec region;
|
||||||
|
|
||||||
box.x1 = x;
|
box.x1 = x;
|
||||||
box.y1 = y;
|
box.y1 = y;
|
||||||
box.x2 = x + width;
|
box.x2 = x + width;
|
||||||
box.y2 = y + height;
|
box.y2 = y + height;
|
||||||
RegionInitBoxes(®ion, &box, 1);
|
RegionInitBoxes(®ion, &box, 1);
|
||||||
clipped_dst_regions = glamor_compute_clipped_regions(dst_pixmap_priv,
|
clipped_dst_regions = glamor_compute_clipped_regions(dst_pixmap_priv,
|
||||||
®ion, &n_dst_region, 0, 0, 0);
|
®ion,
|
||||||
for(i = 0; i < n_dst_region; i++)
|
&n_dst_region, 0,
|
||||||
{
|
0, 0);
|
||||||
int n_src_region;
|
for (i = 0; i < n_dst_region; i++) {
|
||||||
glamor_pixmap_clipped_regions *clipped_src_regions;
|
int n_src_region;
|
||||||
BoxPtr current_boxes;
|
glamor_pixmap_clipped_regions *clipped_src_regions;
|
||||||
int n_current_boxes;
|
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) {
|
if (src_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||||
RegionTranslate(clipped_dst_regions[i].region,
|
RegionTranslate(clipped_dst_regions[i].region,
|
||||||
tile_x - x, tile_y - y);
|
tile_x - x, tile_y - y);
|
||||||
DEBUGF("tiled a large src pixmap. %dx%d \n", tile->drawable.width, tile->drawable.height);
|
DEBUGF("tiled a large src pixmap. %dx%d \n",
|
||||||
clipped_src_regions = glamor_compute_clipped_regions(src_pixmap_priv,
|
tile->drawable.width, tile->drawable.height);
|
||||||
clipped_dst_regions[i].region,
|
clipped_src_regions =
|
||||||
&n_src_region, 1, 0, 0);
|
glamor_compute_clipped_regions(src_pixmap_priv,
|
||||||
DEBUGF("got %d src regions %d \n", n_src_region);
|
clipped_dst_regions[i].
|
||||||
for (j = 0; j < n_src_region; j++)
|
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,
|
RegionTranslate(clipped_src_regions[j].region,
|
||||||
x - tile_x,
|
x - tile_x, y - tile_y);
|
||||||
y - tile_y);
|
current_boxes = RegionRects(clipped_src_regions[j].region);
|
||||||
current_boxes = RegionRects(clipped_src_regions[j].region);
|
n_current_boxes =
|
||||||
n_current_boxes = RegionNumRects(clipped_src_regions[j].region);
|
RegionNumRects(clipped_src_regions[j].region);
|
||||||
for(k = 0; k < n_current_boxes; k++)
|
for (k = 0; k < n_current_boxes; k++) {
|
||||||
{
|
DEBUGF
|
||||||
DEBUGF("Tile on %d %d %d %d dst block id %d tile block id %d tilex %d tiley %d\n",
|
("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].x1, current_boxes[k].y1,
|
||||||
current_boxes[k].x2 - current_boxes[k].x1,
|
current_boxes[k].x2 - current_boxes[k].x1,
|
||||||
current_boxes[k].y2 - current_boxes[k].y1,
|
current_boxes[k].y2 - current_boxes[k].y1,
|
||||||
clipped_dst_regions[i].block_idx,
|
clipped_dst_regions[i].block_idx,
|
||||||
clipped_src_regions[j].block_idx,
|
clipped_src_regions[j].block_idx,
|
||||||
(tile_x + (current_boxes[k].x1 - x)),
|
(tile_x + (current_boxes[k].x1 - x)),
|
||||||
tile_y + (current_boxes[k].y1 - y));
|
tile_y + (current_boxes[k].y1 - y));
|
||||||
|
|
||||||
_glamor_tile(pixmap, tile,
|
_glamor_tile(pixmap, tile,
|
||||||
current_boxes[k].x1, current_boxes[k].y1,
|
current_boxes[k].x1, current_boxes[k].y1,
|
||||||
current_boxes[k].x2 - current_boxes[k].x1,
|
current_boxes[k].x2 - current_boxes[k].x1,
|
||||||
current_boxes[k].y2 - current_boxes[k].y1,
|
current_boxes[k].y2 - current_boxes[k].y1,
|
||||||
(tile_x + (current_boxes[k].x1 - x)),
|
(tile_x + (current_boxes[k].x1 - x)),
|
||||||
(tile_y + (current_boxes[k].y1 - y)));
|
(tile_y + (current_boxes[k].y1 - y)));
|
||||||
}
|
}
|
||||||
|
|
||||||
RegionDestroy(clipped_src_regions[j].region);
|
RegionDestroy(clipped_src_regions[j].region);
|
||||||
}
|
}
|
||||||
free(clipped_src_regions);
|
free(clipped_src_regions);
|
||||||
} else {
|
}
|
||||||
current_boxes = RegionRects(clipped_dst_regions[i].region);
|
else {
|
||||||
n_current_boxes = RegionNumRects(clipped_dst_regions[i].region);
|
current_boxes = RegionRects(clipped_dst_regions[i].region);
|
||||||
for(k = 0; k < n_current_boxes; k++)
|
n_current_boxes = RegionNumRects(clipped_dst_regions[i].region);
|
||||||
{
|
for (k = 0; k < n_current_boxes; k++) {
|
||||||
_glamor_tile(pixmap, tile,
|
_glamor_tile(pixmap, tile,
|
||||||
current_boxes[k].x1, current_boxes[k].y1,
|
current_boxes[k].x1, current_boxes[k].y1,
|
||||||
current_boxes[k].x2 - current_boxes[k].x1,
|
current_boxes[k].x2 - current_boxes[k].x1,
|
||||||
current_boxes[k].y2 - current_boxes[k].y1,
|
current_boxes[k].y2 - current_boxes[k].y1,
|
||||||
(tile_x + (current_boxes[k].x1 - x)),
|
(tile_x + (current_boxes[k].x1 - x)),
|
||||||
(tile_y + (current_boxes[k].y1 - y)));
|
(tile_y + (current_boxes[k].y1 - y)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RegionDestroy(clipped_dst_regions[i].region);
|
RegionDestroy(clipped_dst_regions[i].region);
|
||||||
}
|
}
|
||||||
free(clipped_dst_regions);
|
free(clipped_dst_regions);
|
||||||
RegionUninit(®ion);
|
RegionUninit(®ion);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_glamor_tile(pixmap, tile, x, y, width, height, tile_x, tile_y);
|
_glamor_tile(pixmap, tile, x, y, width, height, tile_x, tile_y);
|
||||||
|
|
||||||
glamor_set_alu(dispatch, GXcopy);
|
glamor_set_alu(dispatch, GXcopy);
|
||||||
glamor_put_dispatch(glamor_priv);
|
glamor_put_dispatch(glamor_priv);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
fail:
|
fail:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -30,51 +30,48 @@
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
_glamor_triangles(CARD8 op,
|
_glamor_triangles(CARD8 op,
|
||||||
PicturePtr pSrc,
|
PicturePtr pSrc,
|
||||||
PicturePtr pDst,
|
PicturePtr pDst,
|
||||||
PictFormatPtr maskFormat,
|
PictFormatPtr maskFormat,
|
||||||
INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris, Bool fallback)
|
INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris,
|
||||||
|
Bool fallback)
|
||||||
{
|
{
|
||||||
if (!fallback
|
if (!fallback && glamor_ddx_fallback_check_pixmap(pDst->pDrawable)
|
||||||
&& glamor_ddx_fallback_check_pixmap(pDst->pDrawable)
|
&& (!pSrc->pDrawable
|
||||||
&& (!pSrc->pDrawable
|
|| glamor_ddx_fallback_check_pixmap(pSrc->pDrawable)))
|
||||||
|| glamor_ddx_fallback_check_pixmap(pSrc->pDrawable)))
|
return FALSE;
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (glamor_prepare_access_picture(pDst, GLAMOR_ACCESS_RW)) {
|
if (glamor_prepare_access_picture(pDst, GLAMOR_ACCESS_RW)) {
|
||||||
if (glamor_prepare_access_picture(pSrc,
|
if (glamor_prepare_access_picture(pSrc, GLAMOR_ACCESS_RO)) {
|
||||||
GLAMOR_ACCESS_RO)) {
|
|
||||||
|
|
||||||
fbTriangles(op, pSrc, pDst, maskFormat, xSrc,
|
fbTriangles(op, pSrc, pDst, maskFormat, xSrc, ySrc, ntris, tris);
|
||||||
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);
|
glamor_finish_access_picture(pDst, GLAMOR_ACCESS_RW);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_triangles(CARD8 op,
|
glamor_triangles(CARD8 op,
|
||||||
PicturePtr pSrc,
|
PicturePtr pSrc,
|
||||||
PicturePtr pDst,
|
PicturePtr pDst,
|
||||||
PictFormatPtr maskFormat,
|
PictFormatPtr maskFormat,
|
||||||
INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris)
|
INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris)
|
||||||
{
|
{
|
||||||
_glamor_triangles(op, pSrc, pDst, maskFormat,
|
_glamor_triangles(op, pSrc, pDst, maskFormat,
|
||||||
xSrc, ySrc, ntris, tris, TRUE);
|
xSrc, ySrc, ntris, tris, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
glamor_triangles_nf(CARD8 op,
|
glamor_triangles_nf(CARD8 op,
|
||||||
PicturePtr pSrc,
|
PicturePtr pSrc,
|
||||||
PicturePtr pDst,
|
PicturePtr pDst,
|
||||||
PictFormatPtr maskFormat,
|
PictFormatPtr maskFormat,
|
||||||
INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris)
|
INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris)
|
||||||
{
|
{
|
||||||
return _glamor_triangles(op, pSrc, pDst, maskFormat,
|
return _glamor_triangles(op, pSrc, pDst, maskFormat,
|
||||||
xSrc, ySrc, ntris, tris, FALSE);
|
xSrc, ySrc, ntris, tris, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -28,76 +28,72 @@
|
||||||
* Screen Change Window Attribute implementation.
|
* Screen Change Window Attribute implementation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
glamor_fixup_window_pixmap(DrawablePtr pDrawable, PixmapPtr * ppPixmap)
|
glamor_fixup_window_pixmap(DrawablePtr pDrawable, PixmapPtr *ppPixmap)
|
||||||
{
|
{
|
||||||
PixmapPtr pPixmap = *ppPixmap;
|
PixmapPtr pPixmap = *ppPixmap;
|
||||||
glamor_pixmap_private *pixmap_priv;
|
glamor_pixmap_private *pixmap_priv;
|
||||||
|
|
||||||
if (pPixmap->drawable.bitsPerPixel != pDrawable->bitsPerPixel) {
|
if (pPixmap->drawable.bitsPerPixel != pDrawable->bitsPerPixel) {
|
||||||
pixmap_priv = glamor_get_pixmap_private(pPixmap);
|
pixmap_priv = glamor_get_pixmap_private(pPixmap);
|
||||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
|
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
|
||||||
glamor_fallback("pixmap %p has no fbo\n", pPixmap);
|
glamor_fallback("pixmap %p has no fbo\n", pPixmap);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
glamor_debug_output(GLAMOR_DEBUG_UNIMPL,
|
glamor_debug_output(GLAMOR_DEBUG_UNIMPL, "To be implemented.\n");
|
||||||
"To be implemented.\n");
|
}
|
||||||
}
|
return;
|
||||||
return;
|
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
GLAMOR_PANIC
|
GLAMOR_PANIC
|
||||||
(" We can't fall back to fbFixupWindowPixmap, as the fb24_32ReformatTile"
|
(" We can't fall back to fbFixupWindowPixmap, as the fb24_32ReformatTile"
|
||||||
" is broken for glamor. \n");
|
" is broken for glamor. \n");
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
glamor_change_window_attributes(WindowPtr pWin, unsigned long mask)
|
glamor_change_window_attributes(WindowPtr pWin, unsigned long mask)
|
||||||
{
|
{
|
||||||
if (mask & CWBackPixmap) {
|
if (mask & CWBackPixmap) {
|
||||||
if (pWin->backgroundState == BackgroundPixmap)
|
if (pWin->backgroundState == BackgroundPixmap)
|
||||||
glamor_fixup_window_pixmap(&pWin->drawable,
|
glamor_fixup_window_pixmap(&pWin->drawable,
|
||||||
&pWin->
|
&pWin->background.pixmap);
|
||||||
background.pixmap);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (mask & CWBorderPixmap) {
|
if (mask & CWBorderPixmap) {
|
||||||
if (pWin->borderIsPixel == FALSE)
|
if (pWin->borderIsPixel == FALSE)
|
||||||
glamor_fixup_window_pixmap(&pWin->drawable,
|
glamor_fixup_window_pixmap(&pWin->drawable, &pWin->border.pixmap);
|
||||||
&pWin->border.pixmap);
|
}
|
||||||
}
|
return TRUE;
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_set_window_pixmap(WindowPtr win, PixmapPtr pPixmap)
|
glamor_set_window_pixmap(WindowPtr win, PixmapPtr pPixmap)
|
||||||
{
|
{
|
||||||
ScreenPtr screen = win->drawable.pScreen;
|
ScreenPtr screen = win->drawable.pScreen;
|
||||||
glamor_screen_private *glamor_priv =
|
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||||
glamor_get_screen_private(screen);
|
PixmapPtr old = screen->GetWindowPixmap(win);
|
||||||
PixmapPtr old = screen->GetWindowPixmap(win);
|
|
||||||
|
|
||||||
if (pPixmap != old) {
|
if (pPixmap != old) {
|
||||||
glamor_pixmap_private *pixmap_priv;
|
glamor_pixmap_private *pixmap_priv;
|
||||||
PicturePtr pic = NULL;
|
PicturePtr pic = NULL;
|
||||||
|
|
||||||
pixmap_priv = glamor_get_pixmap_private(old);
|
pixmap_priv = glamor_get_pixmap_private(old);
|
||||||
if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv) && pixmap_priv->base.picture->pDrawable == (DrawablePtr)win) {
|
if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv) &&
|
||||||
pic = pixmap_priv->base.picture;
|
pixmap_priv->base.picture->pDrawable == (DrawablePtr) win) {
|
||||||
pixmap_priv->base.is_picture = 0;
|
pic = pixmap_priv->base.picture;
|
||||||
pixmap_priv->base.picture = NULL;
|
pixmap_priv->base.is_picture = 0;
|
||||||
}
|
pixmap_priv->base.picture = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
pixmap_priv = glamor_get_pixmap_private(pPixmap);
|
pixmap_priv = glamor_get_pixmap_private(pPixmap);
|
||||||
if (pixmap_priv) {
|
if (pixmap_priv) {
|
||||||
pixmap_priv->base.is_picture = !!pic;
|
pixmap_priv->base.is_picture = ! !pic;
|
||||||
pixmap_priv->base.picture = pic;
|
pixmap_priv->base.picture = pic;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
screen->SetWindowPixmap = glamor_priv->saved_procs.set_window_pixmap;
|
screen->SetWindowPixmap = glamor_priv->saved_procs.set_window_pixmap;
|
||||||
(screen->SetWindowPixmap)(win, pPixmap);
|
(screen->SetWindowPixmap) (win, pPixmap);
|
||||||
glamor_priv->saved_procs.set_window_pixmap = screen->SetWindowPixmap;
|
glamor_priv->saved_procs.set_window_pixmap = screen->SetWindowPixmap;
|
||||||
screen->SetWindowPixmap = glamor_set_window_pixmap;
|
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 */
|
/* Ask fontsproto to make font path element names const */
|
||||||
#define FONT_PATH_ELEMENT_NAME_CONST 1
|
#define FONT_PATH_ELEMENT_NAME_CONST 1
|
||||||
|
|
||||||
|
/* Build GLAMOR */
|
||||||
|
#undef GLAMOR
|
||||||
|
|
||||||
#endif /* _DIX_CONFIG_H_ */
|
#endif /* _DIX_CONFIG_H_ */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user