Merge remote-tracking branch 'anholt/glamor-reformat'
Conflicts: Makefile.am Conflict caused by adding PSEUDORAMIX and GLAMOR directory defines in separate branches
This commit is contained in:
commit
0fbb3d711e
|
@ -31,6 +31,10 @@ if PSEUDORAMIX
|
|||
PSEUDORAMIX_DIR=pseudoramiX
|
||||
endif
|
||||
|
||||
if GLAMOR
|
||||
GLAMOR_DIR=glamor
|
||||
endif
|
||||
|
||||
SUBDIRS = \
|
||||
doc \
|
||||
man \
|
||||
|
@ -55,6 +59,7 @@ SUBDIRS = \
|
|||
$(PRESENT_DIR) \
|
||||
$(DRI3_DIR) \
|
||||
exa \
|
||||
$(GLAMOR_DIR) \
|
||||
config \
|
||||
hw \
|
||||
test
|
||||
|
@ -106,6 +111,7 @@ DIST_SUBDIRS = \
|
|||
composite \
|
||||
glx \
|
||||
exa \
|
||||
$(GLAMOR_DIR) \
|
||||
config \
|
||||
dri3 \
|
||||
present \
|
||||
|
|
10
configure.ac
10
configure.ac
|
@ -636,6 +636,7 @@ AC_ARG_ENABLE(xnest, AS_HELP_STRING([--enable-xnest], [Build Xnest serv
|
|||
AC_ARG_ENABLE(xquartz, AS_HELP_STRING([--enable-xquartz], [Build Xquartz server for OS-X (default: auto)]), [XQUARTZ=$enableval], [XQUARTZ=auto])
|
||||
AC_ARG_ENABLE(standalone-xpbproxy, AS_HELP_STRING([--enable-standalone-xpbproxy], [Build a standalone xpbproxy (in addition to the one integrated into Xquartz as a separate thread) (default: no)]), [STANDALONE_XPBPROXY=$enableval], [STANDALONE_XPBPROXY=no])
|
||||
AC_ARG_ENABLE(xwin, AS_HELP_STRING([--enable-xwin], [Build XWin server (default: auto)]), [XWIN=$enableval], [XWIN=auto])
|
||||
AC_ARG_ENABLE(glamor, AS_HELP_STRING([--enable-glamor], [Build glamor dix module (default: no)]), [GLAMOR=$enableval], [GLAMOR=no])
|
||||
dnl kdrive and its subsystems
|
||||
AC_ARG_ENABLE(kdrive, AS_HELP_STRING([--enable-kdrive], [Build kdrive servers (default: no)]), [KDRIVE=$enableval], [KDRIVE=no])
|
||||
AC_ARG_ENABLE(xephyr, AS_HELP_STRING([--enable-xephyr], [Build the kdrive Xephyr server (default: auto)]), [XEPHYR=$enableval], [XEPHYR=auto])
|
||||
|
@ -2063,6 +2064,14 @@ AM_CONDITIONAL([SOLARIS_VT], [test "x$solaris_vt" = xyes])
|
|||
AM_CONDITIONAL([DGA], [test "x$DGA" = xyes])
|
||||
AM_CONDITIONAL([XF86VIDMODE], [test "x$XF86VIDMODE" = xyes])
|
||||
AM_CONDITIONAL([XORG_BUS_PLATFORM], [test "x$CONFIG_UDEV_KMS" = xyes])
|
||||
|
||||
dnl glamor
|
||||
AM_CONDITIONAL([GLAMOR], [test "x$GLAMOR" = xyes])
|
||||
if test "x$GLAMOR" = xyes; then
|
||||
AC_DEFINE(GLAMOR, 1, [Build glamor])
|
||||
PKG_CHECK_MODULES([GLAMOR], [egl gl])
|
||||
fi
|
||||
|
||||
dnl XWin DDX
|
||||
|
||||
AC_MSG_CHECKING([whether to build XWin DDX])
|
||||
|
@ -2434,6 +2443,7 @@ doc/Makefile
|
|||
doc/dtrace/Makefile
|
||||
man/Makefile
|
||||
fb/Makefile
|
||||
glamor/Makefile
|
||||
record/Makefile
|
||||
config/Makefile
|
||||
mi/Makefile
|
||||
|
|
|
@ -1,18 +1,10 @@
|
|||
lib_LTLIBRARIES = libglamor.la
|
||||
noinst_LTLIBRARIES = libglamor.la libglamor_egl_stubs.la
|
||||
|
||||
if GLAMOR_GLES2
|
||||
libglamor_la_LIBADD = $(GLESV2_LIBS)
|
||||
else
|
||||
libglamor_la_LIBADD = $(GL_LIBS)
|
||||
endif
|
||||
libglamor_la_LIBADD = $(GLAMOR_LIBS)
|
||||
|
||||
AM_CFLAGS = $(CWARNFLAGS) $(XORG_CFLAGS) $(LIBDRM_CFLAGS)
|
||||
|
||||
libglamor_la_LDFLAGS = -version-info 0:0:0
|
||||
AM_CFLAGS = $(CWARNFLAGS) $(DIX_CFLAGS) $(GLAMOR_CFLAGS)
|
||||
|
||||
libglamor_la_SOURCES = \
|
||||
compat-api.h \
|
||||
compiler.h \
|
||||
glamor.c \
|
||||
glamor_copyarea.c \
|
||||
glamor_copywindow.c \
|
||||
|
@ -48,24 +40,8 @@ libglamor_la_SOURCES = \
|
|||
glamor_compositerects.c\
|
||||
glamor_xv.c\
|
||||
glamor_utils.h\
|
||||
glamor.h\
|
||||
glapi.h
|
||||
glamor.h
|
||||
|
||||
libglamor_egl_stubs_la_SOURCES = glamor_egl_stubs.c
|
||||
|
||||
sdk_HEADERS = glamor.h
|
||||
|
||||
if EGL
|
||||
LIBGLAMOREGL = libglamoregl.la
|
||||
module_LTLIBRARIES = $(LIBGLAMOREGL)
|
||||
libglamoregl_la_DEPENDENCIES = libglamor.la
|
||||
libglamoregl_la_LDFLAGS = -avoid-version -module
|
||||
libglamoregl_la_LIBADD = $(EGL_LIBS) $(GLX_SYS_LIBS) $(GBM_LIBS) libglamor.la
|
||||
libglamoregl_la_SOURCES = glamor_eglmodule.c glamor_egl.c
|
||||
libglamoregl_la_CFLAGS = \
|
||||
$(AM_CFLAGS) \
|
||||
$(GLX_DEFINES) \
|
||||
$(LIBDRM_CFLAGS) \
|
||||
$(EGL_CFLAGS) \
|
||||
$(GBM_CFLAGS)
|
||||
endif
|
||||
|
||||
|
||||
|
|
|
@ -1,107 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012 Red Hat, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Author: Dave Airlie <airlied@redhat.com>
|
||||
*/
|
||||
|
||||
/* this file provides API compat between server post 1.13 and pre it,
|
||||
it should be reused inside as many drivers as possible */
|
||||
#ifndef COMPAT_API_H
|
||||
#define COMPAT_API_H
|
||||
|
||||
#ifndef GLYPH_HAS_GLYPH_PICTURE_ACCESSOR
|
||||
#define GetGlyphPicture(g, s) GlyphPicture((g))[(s)->myNum]
|
||||
#define SetGlyphPicture(g, s, p) GlyphPicture((g))[(s)->myNum] = p
|
||||
#endif
|
||||
|
||||
#ifndef XF86_HAS_SCRN_CONV
|
||||
#define xf86ScreenToScrn(s) xf86Screens[(s)->myNum]
|
||||
#define xf86ScrnToScreen(s) screenInfo.screens[(s)->scrnIndex]
|
||||
#endif
|
||||
|
||||
#ifndef XF86_SCRN_INTERFACE
|
||||
|
||||
#define SCRN_ARG_TYPE int
|
||||
#define SCRN_INFO_PTR(arg1) ScrnInfoPtr scrn = xf86Screens[(arg1)]
|
||||
|
||||
#define SCREEN_ARG_TYPE int
|
||||
#define SCREEN_PTR(arg1) ScreenPtr screen = screenInfo.screens[(arg1)]
|
||||
|
||||
#define SCREEN_INIT_ARGS_DECL int scrnIndex, ScreenPtr screen, int argc, char **argv
|
||||
|
||||
#define BLOCKHANDLER_ARGS_DECL int arg, pointer blockData, pointer timeout, pointer read_mask
|
||||
#define BLOCKHANDLER_ARGS arg, blockData, timeout, read_mask
|
||||
|
||||
#define WAKEUPHANDLER_ARGS_DECL int arg, pointer wakeupData, unsigned long result, pointer read_mask
|
||||
#define WAKEUPHANDLER_ARGS arg, wakeupData, result, read_mask
|
||||
|
||||
#define CLOSE_SCREEN_ARGS_DECL int scrnIndex, ScreenPtr screen
|
||||
#define CLOSE_SCREEN_ARGS scrnIndex, screen
|
||||
|
||||
#define ADJUST_FRAME_ARGS_DECL int arg, int x, int y, int flags
|
||||
#define ADJUST_FRAME_ARGS(arg, x, y) (arg)->scrnIndex, x, y, 0
|
||||
|
||||
#define SWITCH_MODE_ARGS_DECL int arg, DisplayModePtr mode, int flags
|
||||
#define SWITCH_MODE_ARGS(arg, m) (arg)->scrnIndex, m, 0
|
||||
|
||||
#define FREE_SCREEN_ARGS_DECL int arg, int flags
|
||||
#define FREE_SCREEN_ARGS arg, flags
|
||||
|
||||
#define VT_FUNC_ARGS_DECL int arg, int flags
|
||||
#define VT_FUNC_ARGS(flags) scrn->scrnIndex, (flags)
|
||||
|
||||
#define XF86_ENABLEDISABLEFB_ARG(x) ((x)->scrnIndex)
|
||||
|
||||
#else
|
||||
#define SCRN_ARG_TYPE ScrnInfoPtr
|
||||
#define SCRN_INFO_PTR(arg1) ScrnInfoPtr scrn = (arg1)
|
||||
|
||||
#define SCREEN_ARG_TYPE ScreenPtr
|
||||
#define SCREEN_PTR(arg1) ScreenPtr screen = (arg1)
|
||||
|
||||
#define SCREEN_INIT_ARGS_DECL ScreenPtr screen, int argc, char **argv
|
||||
|
||||
#define BLOCKHANDLER_ARGS_DECL ScreenPtr arg, pointer timeout, pointer read_mask
|
||||
#define BLOCKHANDLER_ARGS arg, timeout, read_mask
|
||||
|
||||
#define WAKEUPHANDLER_ARGS_DECL ScreenPtr arg, unsigned long result, pointer read_mask
|
||||
#define WAKEUPHANDLER_ARGS arg, result, read_mask
|
||||
|
||||
#define CLOSE_SCREEN_ARGS_DECL ScreenPtr screen
|
||||
#define CLOSE_SCREEN_ARGS screen
|
||||
|
||||
#define ADJUST_FRAME_ARGS_DECL ScrnInfoPtr arg, int x, int y
|
||||
#define ADJUST_FRAME_ARGS(arg, x, y) arg, x, y
|
||||
|
||||
#define SWITCH_MODE_ARGS_DECL ScrnInfoPtr arg, DisplayModePtr mode
|
||||
#define SWITCH_MODE_ARGS(arg, m) arg, m
|
||||
|
||||
#define FREE_SCREEN_ARGS_DECL ScrnInfoPtr arg
|
||||
#define FREE_SCREEN_ARGS arg
|
||||
|
||||
#define VT_FUNC_ARGS_DECL ScrnInfoPtr arg
|
||||
#define VT_FUNC_ARGS(flags) scrn
|
||||
|
||||
#define XF86_ENABLEDISABLEFB_ARG(x) (x)
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -55,8 +55,7 @@ PixmapPtr
|
|||
glamor_get_drawable_pixmap(DrawablePtr drawable)
|
||||
{
|
||||
if (drawable->type == DRAWABLE_WINDOW)
|
||||
return drawable->
|
||||
pScreen->GetWindowPixmap((WindowPtr) drawable);
|
||||
return drawable->pScreen->GetWindowPixmap((WindowPtr) drawable);
|
||||
else
|
||||
return (PixmapPtr) drawable;
|
||||
}
|
||||
|
@ -98,8 +97,7 @@ glamor_set_pixmap_texture(PixmapPtr pixmap, unsigned int tex)
|
|||
|
||||
gl_iformat_for_depth(pixmap->drawable.depth, &format);
|
||||
fbo = glamor_create_fbo_from_tex(glamor_priv, pixmap->drawable.width,
|
||||
pixmap->drawable.height,
|
||||
format, tex, 0);
|
||||
pixmap->drawable.height, format, tex, 0);
|
||||
|
||||
if (fbo == NULL) {
|
||||
ErrorF("XXX fail to create fbo.\n");
|
||||
|
@ -132,8 +130,7 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
|||
PixmapPtr pixmap;
|
||||
glamor_pixmap_type_t type = GLAMOR_TEXTURE_ONLY;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_pixmap_fbo *fbo;
|
||||
int pitch;
|
||||
GLenum format;
|
||||
|
@ -179,8 +176,7 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
|||
pixmap_priv->type = GLAMOR_TEXTURE_LARGE;
|
||||
fbo = glamor_create_fbo_array(glamor_priv, w, h, format, usage,
|
||||
glamor_priv->max_fbo_size,
|
||||
glamor_priv->max_fbo_size,
|
||||
pixmap_priv);
|
||||
glamor_priv->max_fbo_size, pixmap_priv);
|
||||
}
|
||||
|
||||
if (fbo == NULL) {
|
||||
|
@ -221,8 +217,7 @@ glamor_destroy_pixmap(PixmapPtr pixmap)
|
|||
void
|
||||
glamor_block_handler(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_gl_dispatch *dispatch;
|
||||
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
|
@ -238,11 +233,11 @@ glamor_block_handler(ScreenPtr screen)
|
|||
}
|
||||
|
||||
static void
|
||||
_glamor_block_handler(void *data, OSTimePtr timeout,
|
||||
void *last_select_mask)
|
||||
_glamor_block_handler(void *data, OSTimePtr timeout, void *last_select_mask)
|
||||
{
|
||||
glamor_screen_private *glamor_priv = data;
|
||||
glamor_gl_dispatch *dispatch = glamor_get_dispatch(glamor_priv);
|
||||
|
||||
dispatch->glFlush();
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
}
|
||||
|
@ -256,6 +251,7 @@ static void
|
|||
glamor_set_debug_level(int *debug_level)
|
||||
{
|
||||
char *debug_level_string;
|
||||
|
||||
debug_level_string = getenv("GLAMOR_DEBUG");
|
||||
if (debug_level_string
|
||||
&& sscanf(debug_level_string, "%d", debug_level) == 1)
|
||||
|
@ -265,6 +261,7 @@ glamor_set_debug_level(int *debug_level)
|
|||
|
||||
int glamor_debug_level;
|
||||
|
||||
|
||||
/** Set up glamor for an already-configured GL context. */
|
||||
Bool
|
||||
glamor_init(ScreenPtr screen, unsigned int flags)
|
||||
|
@ -285,11 +282,11 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
|
||||
if (flags & GLAMOR_INVERTED_Y_AXIS) {
|
||||
glamor_priv->yInverted = 1;
|
||||
} else
|
||||
}
|
||||
else
|
||||
glamor_priv->yInverted = 0;
|
||||
|
||||
if (!dixRegisterPrivateKey
|
||||
(glamor_screen_private_key, PRIVATE_SCREEN, 0)) {
|
||||
if (!dixRegisterPrivateKey(glamor_screen_private_key, PRIVATE_SCREEN, 0)) {
|
||||
LogMessage(X_WARNING,
|
||||
"glamor%d: Failed to allocate screen private\n",
|
||||
screen->myNum);
|
||||
|
@ -298,8 +295,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
|
||||
glamor_set_screen_private(screen, glamor_priv);
|
||||
|
||||
if (!dixRegisterPrivateKey
|
||||
(glamor_pixmap_private_key, PRIVATE_PIXMAP, 0)) {
|
||||
if (!dixRegisterPrivateKey(glamor_pixmap_private_key, PRIVATE_PIXMAP, 0)) {
|
||||
LogMessage(X_WARNING,
|
||||
"glamor%d: Failed to allocate pixmap private\n",
|
||||
screen->myNum);
|
||||
|
@ -378,14 +374,12 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
|
||||
glamor_priv->saved_procs.change_window_attributes =
|
||||
screen->ChangeWindowAttributes;
|
||||
screen->ChangeWindowAttributes =
|
||||
glamor_change_window_attributes;
|
||||
screen->ChangeWindowAttributes = glamor_change_window_attributes;
|
||||
|
||||
glamor_priv->saved_procs.copy_window = screen->CopyWindow;
|
||||
screen->CopyWindow = glamor_copy_window;
|
||||
|
||||
glamor_priv->saved_procs.bitmap_to_region =
|
||||
screen->BitmapToRegion;
|
||||
glamor_priv->saved_procs.bitmap_to_region = screen->BitmapToRegion;
|
||||
screen->BitmapToRegion = glamor_bitmap_to_region;
|
||||
}
|
||||
#ifdef RENDER
|
||||
|
@ -393,11 +387,9 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
glamor_priv->saved_procs.composite = ps->Composite;
|
||||
ps->Composite = glamor_composite;
|
||||
|
||||
|
||||
glamor_priv->saved_procs.trapezoids = ps->Trapezoids;
|
||||
ps->Trapezoids = glamor_trapezoids;
|
||||
|
||||
|
||||
glamor_priv->saved_procs.triangles = ps->Triangles;
|
||||
ps->Triangles = glamor_triangles;
|
||||
|
||||
|
@ -491,7 +483,8 @@ glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv)
|
|||
|
||||
if (priv) {
|
||||
assert(old_priv == NULL);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (old_priv == NULL)
|
||||
return;
|
||||
fbo = glamor_pixmap_detach_fbo(old_priv);
|
||||
|
@ -499,17 +492,16 @@ glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv)
|
|||
free(old_priv);
|
||||
}
|
||||
|
||||
dixSetPrivate(&pixmap->devPrivates,
|
||||
glamor_pixmap_private_key,
|
||||
priv);
|
||||
dixSetPrivate(&pixmap->devPrivates, glamor_pixmap_private_key, priv);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_close_screen(CLOSE_SCREEN_ARGS_DECL)
|
||||
glamor_close_screen(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv;
|
||||
PixmapPtr screen_pixmap;
|
||||
int flags;
|
||||
|
||||
#ifdef RENDER
|
||||
PictureScreenPtr ps = GetPictureScreenIfSet(screen);
|
||||
#endif
|
||||
|
@ -548,35 +540,34 @@ glamor_close_screen(CLOSE_SCREEN_ARGS_DECL)
|
|||
|
||||
glamor_release_screen_priv(screen);
|
||||
|
||||
return screen->CloseScreen(CLOSE_SCREEN_ARGS);
|
||||
return screen->CloseScreen(screen);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
glamor_fini(ScreenPtr screen)
|
||||
{
|
||||
/* Do nothing currently. */
|
||||
}
|
||||
|
||||
void glamor_enable_dri3(ScreenPtr screen)
|
||||
void
|
||||
glamor_enable_dri3(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
|
||||
glamor_priv->dri3_enabled = TRUE;
|
||||
}
|
||||
|
||||
Bool glamor_is_dri3_support_enabled(ScreenPtr screen)
|
||||
Bool
|
||||
glamor_is_dri3_support_enabled(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
|
||||
return glamor_priv->dri3_enabled;
|
||||
}
|
||||
|
||||
int
|
||||
glamor_dri3_fd_from_pixmap (ScreenPtr screen,
|
||||
PixmapPtr pixmap,
|
||||
CARD16 *stride,
|
||||
CARD32 *size)
|
||||
glamor_dri3_fd_from_pixmap(ScreenPtr screen,
|
||||
PixmapPtr pixmap, CARD16 *stride, CARD32 *size)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv =
|
||||
|
@ -585,24 +576,22 @@ glamor_dri3_fd_from_pixmap (ScreenPtr screen,
|
|||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
if (pixmap_priv == NULL || !glamor_priv->dri3_enabled)
|
||||
return -1;
|
||||
switch (pixmap_priv->type)
|
||||
{
|
||||
switch (pixmap_priv->type) {
|
||||
case GLAMOR_TEXTURE_DRM:
|
||||
case GLAMOR_TEXTURE_ONLY:
|
||||
glamor_pixmap_ensure_fbo(pixmap, GL_RGBA, 0);
|
||||
return glamor_egl_dri3_fd_name_from_tex(screen,
|
||||
pixmap,
|
||||
pixmap_priv->base.fbo->tex,
|
||||
FALSE,
|
||||
stride,
|
||||
size);
|
||||
default: break;
|
||||
FALSE, stride, size);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
glamor_dri3_name_from_pixmap (PixmapPtr pixmap)
|
||||
glamor_dri3_name_from_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv =
|
||||
|
@ -611,18 +600,16 @@ glamor_dri3_name_from_pixmap (PixmapPtr pixmap)
|
|||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
if (pixmap_priv == NULL || !glamor_priv->dri3_enabled)
|
||||
return -1;
|
||||
switch (pixmap_priv->type)
|
||||
{
|
||||
switch (pixmap_priv->type) {
|
||||
case GLAMOR_TEXTURE_DRM:
|
||||
case GLAMOR_TEXTURE_ONLY:
|
||||
glamor_pixmap_ensure_fbo(pixmap, GL_RGBA, 0);
|
||||
return glamor_egl_dri3_fd_name_from_tex(pixmap->drawable.pScreen,
|
||||
pixmap,
|
||||
pixmap_priv->base.fbo->tex,
|
||||
TRUE,
|
||||
NULL,
|
||||
NULL);
|
||||
default: break;
|
||||
TRUE, NULL, NULL);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
135
glamor/glamor.h
135
glamor/glamor.h
|
@ -30,14 +30,12 @@
|
|||
#define GLAMOR_H
|
||||
|
||||
#include <scrnintstr.h>
|
||||
#include <xf86.h>
|
||||
#include <xf86str.h>
|
||||
#include <pixmapstr.h>
|
||||
#include <gcstruct.h>
|
||||
#include <picturestr.h>
|
||||
#include <fb.h>
|
||||
#include <fbpict.h>
|
||||
#include <xf86xv.h>
|
||||
|
||||
/*
|
||||
* glamor_pixmap_type : glamor pixmap's type.
|
||||
* @MEMORY: pixmap is in memory.
|
||||
|
@ -116,17 +114,13 @@ extern _X_EXPORT void glamor_fini(ScreenPtr screen);
|
|||
* screen pixmap which must be a glamor pixmap and requires
|
||||
* the internal data structure still exist at that time.
|
||||
* Otherwise, the glamor internal structure will not be freed.*/
|
||||
#ifndef XF86_SCRN_INTERFACE
|
||||
extern _X_EXPORT Bool glamor_close_screen(int scrnIndex, ScreenPtr screen);
|
||||
#else
|
||||
extern _X_EXPORT Bool glamor_close_screen(ScreenPtr screen);
|
||||
#endif
|
||||
|
||||
|
||||
/* Let glamor to know the screen's fbo. The low level
|
||||
* driver should already assign a tex
|
||||
* to this pixmap through the set_pixmap_texture. */
|
||||
extern _X_EXPORT void glamor_set_screen_pixmap(PixmapPtr screen_pixmap, PixmapPtr *back_pixmap);
|
||||
extern _X_EXPORT void glamor_set_screen_pixmap(PixmapPtr screen_pixmap,
|
||||
PixmapPtr *back_pixmap);
|
||||
|
||||
/* @glamor_glyphs_init: Initialize glyphs internal data structures.
|
||||
*
|
||||
|
@ -141,11 +135,12 @@ extern _X_EXPORT Bool glamor_glyphs_init(ScreenPtr pScreen);
|
|||
extern _X_EXPORT void glamor_set_pixmap_texture(PixmapPtr pixmap,
|
||||
unsigned int tex);
|
||||
|
||||
extern _X_EXPORT void glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type);
|
||||
extern _X_EXPORT void glamor_set_pixmap_type(PixmapPtr pixmap,
|
||||
glamor_pixmap_type_t type);
|
||||
extern _X_EXPORT void glamor_destroy_textured_pixmap(PixmapPtr pixmap);
|
||||
extern _X_EXPORT void glamor_block_handler(ScreenPtr screen);
|
||||
extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
||||
unsigned int usage);
|
||||
extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h,
|
||||
int depth, unsigned int usage);
|
||||
|
||||
extern _X_EXPORT void glamor_egl_screen_init(ScreenPtr screen);
|
||||
|
||||
|
@ -160,14 +155,21 @@ extern _X_EXPORT void glamor_egl_restore_context(ScreenPtr screen);
|
|||
* Used by the DRI2 page flip. This function will exchange the KHR images and
|
||||
* fbos of the two pixmaps.
|
||||
* */
|
||||
extern _X_EXPORT void glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr back);
|
||||
extern _X_EXPORT void glamor_egl_exchange_buffers(PixmapPtr front,
|
||||
PixmapPtr back);
|
||||
|
||||
extern _X_EXPORT void glamor_pixmap_exchange_fbos(PixmapPtr front, PixmapPtr back);
|
||||
extern _X_EXPORT void glamor_pixmap_exchange_fbos(PixmapPtr front,
|
||||
PixmapPtr back);
|
||||
|
||||
/* The DDX is not supposed to call these three functions */
|
||||
extern _X_EXPORT void glamor_enable_dri3(ScreenPtr screen);
|
||||
extern _X_EXPORT unsigned int glamor_egl_create_argb8888_based_texture(ScreenPtr screen, int w, int h);
|
||||
extern _X_EXPORT int glamor_egl_dri3_fd_name_from_tex(ScreenPtr, PixmapPtr, unsigned int, Bool, CARD16*, CARD32*);
|
||||
extern _X_EXPORT unsigned int glamor_egl_create_argb8888_based_texture(ScreenPtr
|
||||
screen,
|
||||
int w,
|
||||
int h);
|
||||
extern _X_EXPORT int glamor_egl_dri3_fd_name_from_tex(ScreenPtr, PixmapPtr,
|
||||
unsigned int, Bool,
|
||||
CARD16 *, CARD32 *);
|
||||
|
||||
/* @glamor_is_dri3_support_enabled: Returns if DRI3 support is enabled.
|
||||
*
|
||||
|
@ -194,10 +196,9 @@ extern _X_EXPORT Bool glamor_is_dri3_support_enabled(ScreenPtr screen);
|
|||
* content.
|
||||
* Returns the fd on success, -1 on error.
|
||||
* */
|
||||
extern _X_EXPORT int glamor_dri3_fd_from_pixmap (ScreenPtr screen,
|
||||
extern _X_EXPORT int glamor_dri3_fd_from_pixmap(ScreenPtr screen,
|
||||
PixmapPtr pixmap,
|
||||
CARD16 *stride,
|
||||
CARD32 *size);
|
||||
CARD16 *stride, CARD32 *size);
|
||||
|
||||
/* @glamor_dri3_name_from_pixmap: helper to get an gem name from a pixmap.
|
||||
*
|
||||
|
@ -208,7 +209,7 @@ extern _X_EXPORT int glamor_dri3_fd_from_pixmap (ScreenPtr screen,
|
|||
* glamor DRI3 support to be activated.
|
||||
* Returns the name on success, -1 on error.
|
||||
* */
|
||||
extern _X_EXPORT int glamor_dri3_name_from_pixmap (PixmapPtr pixmap);
|
||||
extern _X_EXPORT int glamor_dri3_name_from_pixmap(PixmapPtr pixmap);
|
||||
|
||||
/* @glamor_egl_dri3_pixmap_from_fd: DRI3 helper to get a pixmap from a dma-buf fd.
|
||||
*
|
||||
|
@ -222,7 +223,7 @@ extern _X_EXPORT int glamor_dri3_name_from_pixmap (PixmapPtr pixmap);
|
|||
*
|
||||
* Returns a valid pixmap if the import succeeded, else NULL.
|
||||
* */
|
||||
extern _X_EXPORT PixmapPtr glamor_egl_dri3_pixmap_from_fd (ScreenPtr screen,
|
||||
extern _X_EXPORT PixmapPtr glamor_egl_dri3_pixmap_from_fd(ScreenPtr screen,
|
||||
int fd,
|
||||
CARD16 width,
|
||||
CARD16 height,
|
||||
|
@ -265,8 +266,7 @@ extern _X_EXPORT Bool glamor_egl_init_textured_pixmap(ScreenPtr screen);
|
|||
* screen pixmap is a special, we handle it separately in this function.
|
||||
*/
|
||||
extern _X_EXPORT Bool glamor_egl_create_textured_screen(ScreenPtr screen,
|
||||
int handle,
|
||||
int stride);
|
||||
int handle, int stride);
|
||||
|
||||
/* @glamor_egl_create_textured_screen_ext:
|
||||
*
|
||||
|
@ -277,7 +277,8 @@ extern _X_EXPORT Bool glamor_egl_create_textured_screen(ScreenPtr screen,
|
|||
extern _X_EXPORT Bool glamor_egl_create_textured_screen_ext(ScreenPtr screen,
|
||||
int handle,
|
||||
int stride,
|
||||
PixmapPtr *back_pixmap);
|
||||
PixmapPtr
|
||||
*back_pixmap);
|
||||
|
||||
/*
|
||||
* @glamor_egl_create_textured_pixmap: Try to create a textured pixmap from
|
||||
|
@ -292,8 +293,7 @@ extern _X_EXPORT Bool glamor_egl_create_textured_screen_ext(ScreenPtr screen,
|
|||
* as well. Return true if successful, otherwise return FALSE.
|
||||
*/
|
||||
extern _X_EXPORT Bool glamor_egl_create_textured_pixmap(PixmapPtr pixmap,
|
||||
int handle,
|
||||
int stride);
|
||||
int handle, int stride);
|
||||
|
||||
/*
|
||||
* @glamor_egl_create_textured_pixmap_from_bo: Try to create a textured pixmap
|
||||
|
@ -305,8 +305,7 @@ extern _X_EXPORT Bool glamor_egl_create_textured_pixmap(PixmapPtr pixmap,
|
|||
* This function is similar to glamor_egl_create_textured_pixmap.
|
||||
*/
|
||||
extern _X_EXPORT Bool
|
||||
glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap,
|
||||
void *bo);
|
||||
glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -314,7 +313,8 @@ extern _X_EXPORT void glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap);
|
|||
|
||||
extern _X_EXPORT int glamor_create_gc(GCPtr gc);
|
||||
|
||||
extern _X_EXPORT void glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable);
|
||||
extern _X_EXPORT void glamor_validate_gc(GCPtr gc, unsigned long changes,
|
||||
DrawablePtr drawable);
|
||||
/* Glamor rendering/drawing functions with XXX_nf.
|
||||
* nf means no fallback within glamor internal if possible. If glamor
|
||||
* fail to accelerate the operation, glamor will return a false, and the
|
||||
|
@ -327,8 +327,7 @@ extern _X_EXPORT Bool glamor_fill_spans_nf(DrawablePtr drawable,
|
|||
|
||||
extern _X_EXPORT Bool glamor_poly_fill_rect_nf(DrawablePtr drawable,
|
||||
GCPtr gc,
|
||||
int nrect,
|
||||
xRectangle * prect);
|
||||
int nrect, xRectangle *prect);
|
||||
|
||||
extern _X_EXPORT Bool glamor_put_image_nf(DrawablePtr drawable,
|
||||
GCPtr gc, int depth, int x, int y,
|
||||
|
@ -361,7 +360,7 @@ extern _X_EXPORT Bool glamor_trapezoids_nf(CARD8 op,
|
|||
PicturePtr src, PicturePtr dst,
|
||||
PictFormatPtr mask_format,
|
||||
INT16 x_src, INT16 y_src,
|
||||
int ntrap, xTrapezoid * traps);
|
||||
int ntrap, xTrapezoid *traps);
|
||||
|
||||
extern _X_EXPORT Bool glamor_glyphs_nf(CARD8 op,
|
||||
PicturePtr src,
|
||||
|
@ -369,64 +368,76 @@ extern _X_EXPORT Bool glamor_glyphs_nf(CARD8 op,
|
|||
PictFormatPtr mask_format,
|
||||
INT16 x_src,
|
||||
INT16 y_src, int nlist,
|
||||
GlyphListPtr list, GlyphPtr * glyphs);
|
||||
GlyphListPtr list, GlyphPtr *glyphs);
|
||||
|
||||
extern _X_EXPORT Bool glamor_triangles_nf(CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc, INT16 ySrc,
|
||||
int ntris, xTriangle * tris);
|
||||
|
||||
int ntris, xTriangle *tris);
|
||||
|
||||
extern _X_EXPORT void glamor_glyph_unrealize(ScreenPtr screen, GlyphPtr glyph);
|
||||
|
||||
extern _X_EXPORT Bool glamor_set_spans_nf(DrawablePtr drawable, GCPtr gc, char *src,
|
||||
DDXPointPtr points, int *widths, int n, int sorted);
|
||||
extern _X_EXPORT Bool glamor_set_spans_nf(DrawablePtr drawable, GCPtr gc,
|
||||
char *src, DDXPointPtr points,
|
||||
int *widths, int n, int sorted);
|
||||
|
||||
extern _X_EXPORT Bool glamor_get_spans_nf(DrawablePtr drawable, int wmax,
|
||||
DDXPointPtr points, int *widths, int count, char *dst);
|
||||
DDXPointPtr points, int *widths,
|
||||
int count, char *dst);
|
||||
|
||||
extern _X_EXPORT Bool glamor_composite_rects_nf (CARD8 op,
|
||||
extern _X_EXPORT Bool glamor_composite_rects_nf(CARD8 op,
|
||||
PicturePtr pDst,
|
||||
xRenderColor *color,
|
||||
int nRect,
|
||||
xRectangle *rects);
|
||||
int nRect, xRectangle *rects);
|
||||
|
||||
extern _X_EXPORT Bool glamor_get_image_nf(DrawablePtr pDrawable, int x, int y, int w, int h,
|
||||
unsigned int format, unsigned long planeMask, char *d);
|
||||
extern _X_EXPORT Bool glamor_get_image_nf(DrawablePtr pDrawable, int x, int y,
|
||||
int w, int h, unsigned int format,
|
||||
unsigned long planeMask, char *d);
|
||||
|
||||
extern _X_EXPORT Bool glamor_add_traps_nf(PicturePtr pPicture,
|
||||
INT16 x_off,
|
||||
INT16 y_off, int ntrap, xTrap * traps);
|
||||
INT16 y_off, int ntrap,
|
||||
xTrap *traps);
|
||||
|
||||
extern _X_EXPORT Bool glamor_copy_plane_nf(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
|
||||
int srcx, int srcy, int w, int h, int dstx, int dsty,
|
||||
unsigned long bitPlane, RegionPtr *pRegion);
|
||||
extern _X_EXPORT Bool glamor_copy_plane_nf(DrawablePtr pSrc, DrawablePtr pDst,
|
||||
GCPtr pGC, int srcx, int srcy, int w,
|
||||
int h, int dstx, int dsty,
|
||||
unsigned long bitPlane,
|
||||
RegionPtr *pRegion);
|
||||
|
||||
extern _X_EXPORT Bool glamor_image_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr * ppci, pointer pglyphBase);
|
||||
extern _X_EXPORT Bool glamor_image_glyph_blt_nf(DrawablePtr pDrawable,
|
||||
GCPtr pGC, int x, int y,
|
||||
unsigned int nglyph,
|
||||
CharInfoPtr *ppci,
|
||||
void *pglyphBase);
|
||||
|
||||
extern _X_EXPORT Bool glamor_poly_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr * ppci, pointer pglyphBase);
|
||||
int x, int y,
|
||||
unsigned int nglyph,
|
||||
CharInfoPtr *ppci,
|
||||
void *pglyphBase);
|
||||
|
||||
extern _X_EXPORT Bool glamor_push_pixels_nf(GCPtr pGC, PixmapPtr pBitmap,
|
||||
DrawablePtr pDrawable, int w, int h, int x, int y);
|
||||
DrawablePtr pDrawable, int w, int h,
|
||||
int x, int y);
|
||||
|
||||
extern _X_EXPORT Bool glamor_poly_point_nf(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
||||
DDXPointPtr ppt);
|
||||
extern _X_EXPORT Bool glamor_poly_point_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int mode, int npt, DDXPointPtr ppt);
|
||||
|
||||
extern _X_EXPORT Bool glamor_poly_segment_nf(DrawablePtr pDrawable, GCPtr pGC, int nseg,
|
||||
xSegment *pSeg);
|
||||
extern _X_EXPORT Bool glamor_poly_segment_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int nseg, xSegment *pSeg);
|
||||
|
||||
extern _X_EXPORT Bool glamor_poly_line_nf(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
||||
DDXPointPtr ppt);
|
||||
extern _X_EXPORT Bool glamor_poly_line_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int mode, int npt, DDXPointPtr ppt);
|
||||
|
||||
extern _X_EXPORT Bool glamor_poly_lines_nf(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
||||
DDXPointPtr points);
|
||||
extern _X_EXPORT Bool glamor_poly_lines_nf(DrawablePtr drawable, GCPtr gc,
|
||||
int mode, int n, DDXPointPtr points);
|
||||
|
||||
extern _X_EXPORT XF86VideoAdaptorPtr glamor_xv_init(ScreenPtr pScreen, int num_texture_ports);
|
||||
#if 0
|
||||
extern _X_EXPORT XF86VideoAdaptorPtr glamor_xv_init(ScreenPtr pScreen,
|
||||
int num_texture_ports);
|
||||
#endif
|
||||
|
||||
#endif /* GLAMOR_H */
|
||||
|
|
|
@ -31,11 +31,10 @@
|
|||
static Bool
|
||||
_glamor_add_traps(PicturePtr pPicture,
|
||||
INT16 x_off,
|
||||
INT16 y_off, int ntrap, xTrap * traps,
|
||||
Bool fallback)
|
||||
INT16 y_off, int ntrap, xTrap *traps, Bool fallback)
|
||||
{
|
||||
if (!fallback
|
||||
&& ( !pPicture->pDrawable
|
||||
&& (!pPicture->pDrawable
|
||||
|| glamor_ddx_fallback_check_pixmap(pPicture->pDrawable)))
|
||||
return FALSE;
|
||||
|
||||
|
@ -49,17 +48,14 @@ _glamor_add_traps(PicturePtr pPicture,
|
|||
|
||||
void
|
||||
glamor_add_traps(PicturePtr pPicture,
|
||||
INT16 x_off,
|
||||
INT16 y_off, int ntrap, xTrap * traps)
|
||||
INT16 x_off, INT16 y_off, int ntrap, xTrap *traps)
|
||||
{
|
||||
_glamor_add_traps(pPicture, x_off, y_off, ntrap, traps, TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_add_traps_nf(PicturePtr pPicture,
|
||||
INT16 x_off,
|
||||
INT16 y_off, int ntrap, xTrap * traps)
|
||||
INT16 x_off, INT16 y_off, int ntrap, xTrap *traps)
|
||||
{
|
||||
return _glamor_add_traps(pPicture, x_off, y_off, ntrap, traps, FALSE);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,20 +36,21 @@
|
|||
* 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;
|
||||
return v;
|
||||
}
|
||||
|
||||
static Bool
|
||||
_pixman_region_init_clipped_rectangles(pixman_region16_t *region,
|
||||
_pixman_region_init_clipped_rectangles(pixman_region16_t * region,
|
||||
unsigned int num_rects,
|
||||
xRectangle *rects,
|
||||
int tx, int ty,
|
||||
BoxPtr extents)
|
||||
int tx, int ty, BoxPtr extents)
|
||||
{
|
||||
pixman_box16_t stack_boxes[64], *boxes = stack_boxes;
|
||||
pixman_bool_t ret;
|
||||
|
@ -92,18 +93,15 @@ _pixman_region_init_clipped_rectangles(pixman_region16_t *region,
|
|||
DEBUGF("%s: nrects=%d, region=(%d, %d), (%d, %d) x %d\n",
|
||||
__FUNCTION__, num_rects,
|
||||
region->extents.x1, region->extents.y1,
|
||||
region->extents.x2, region->extents.y2,
|
||||
j);
|
||||
region->extents.x2, region->extents.y2, j);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
glamor_composite_rectangles(CARD8 op,
|
||||
PicturePtr dst,
|
||||
xRenderColor *color,
|
||||
int num_rects,
|
||||
xRectangle *rects)
|
||||
xRenderColor * color,
|
||||
int num_rects, xRectangle *rects)
|
||||
{
|
||||
PixmapPtr pixmap;
|
||||
struct glamor_pixmap_private *priv;
|
||||
|
@ -120,18 +118,17 @@ glamor_composite_rectangles(CARD8 op,
|
|||
(color->red >> 8 << 16) |
|
||||
(color->green >> 8 << 8) |
|
||||
(color->blue >> 8 << 0),
|
||||
num_rects,
|
||||
rects[0].x, rects[0].y, rects[0].width, rects[0].height);
|
||||
num_rects, rects[0].x, rects[0].y, rects[0].width, rects[0].height);
|
||||
|
||||
if (!num_rects)
|
||||
return;
|
||||
|
||||
if (region_is_empty(dst->pCompositeClip)) {
|
||||
if (RegionNil(dst->pCompositeClip)) {
|
||||
DEBUGF("%s: empty clip, skipping\n", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((color->red|color->green|color->blue|color->alpha) <= 0x00ff) {
|
||||
if ((color->red | color->green | color->blue | color->alpha) <= 0x00ff) {
|
||||
switch (op) {
|
||||
case PictOpOver:
|
||||
case PictOpOutReverse:
|
||||
|
@ -164,7 +161,8 @@ glamor_composite_rectangles(CARD8 op,
|
|||
op = PictOpOverReverse;
|
||||
break;
|
||||
}
|
||||
} else if (color->alpha >= 0xff00) {
|
||||
}
|
||||
else if (color->alpha >= 0xff00) {
|
||||
switch (op) {
|
||||
case PictOpOver:
|
||||
op = PictOpSrc;
|
||||
|
@ -214,7 +212,7 @@ glamor_composite_rectangles(CARD8 op,
|
|||
|
||||
if (dst->pCompositeClip->data &&
|
||||
(!pixman_region_intersect(®ion, ®ion, dst->pCompositeClip) ||
|
||||
region_is_empty(®ion))) {
|
||||
RegionNil(®ion))) {
|
||||
DEBUGF("%s: zero-intersection between rectangles and clip\n",
|
||||
__FUNCTION__);
|
||||
pixman_region_fini(®ion);
|
||||
|
@ -235,10 +233,10 @@ glamor_composite_rectangles(CARD8 op,
|
|||
RegionExtents(®ion)->x1, RegionExtents(®ion)->y1,
|
||||
RegionExtents(®ion)->x2, RegionExtents(®ion)->y2);
|
||||
|
||||
|
||||
boxes = pixman_region_rectangles(®ion, &num_boxes);
|
||||
if (op == PictOpSrc || op == PictOpClear) {
|
||||
CARD32 pixel;
|
||||
|
||||
if (op == PictOpClear)
|
||||
pixel = 0;
|
||||
else
|
||||
|
@ -246,8 +244,9 @@ glamor_composite_rectangles(CARD8 op,
|
|||
glamor_solid_boxes(pixmap, boxes, num_boxes, pixel);
|
||||
|
||||
goto done;
|
||||
} else {
|
||||
if (likely(priv->type != GLAMOR_TEXTURE_LARGE)) {
|
||||
}
|
||||
else {
|
||||
if (_X_LIKELY(priv->type != GLAMOR_TEXTURE_LARGE)) {
|
||||
int error;
|
||||
|
||||
source = CreateSolidPicture(0, color, &error);
|
||||
|
@ -256,14 +255,13 @@ glamor_composite_rectangles(CARD8 op,
|
|||
if (glamor_composite_clipped_region(op, source,
|
||||
NULL, dst,
|
||||
NULL, NULL, priv,
|
||||
®ion,
|
||||
0,0,0,0,0,0))
|
||||
®ion, 0, 0, 0, 0, 0, 0))
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
fallback:
|
||||
fallback:
|
||||
miCompositeRects(op, dst, color, num_rects, rects);
|
||||
done:
|
||||
done:
|
||||
/* XXX xserver-1.8: CompositeRects is not tracked by Damage, so we must
|
||||
* manually append the damaged regions ourselves.
|
||||
*/
|
||||
|
|
|
@ -41,16 +41,14 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
|
|||
PixmapPtr dst_pixmap = glamor_get_drawable_pixmap(dst);
|
||||
PixmapPtr src_pixmap = glamor_get_drawable_pixmap(src);
|
||||
glamor_pixmap_private *src_pixmap_priv, *dst_pixmap_priv;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_gl_dispatch *dispatch;
|
||||
int dst_x_off, dst_y_off, src_x_off, src_y_off, i;
|
||||
int fbo_x_off, fbo_y_off;
|
||||
int src_fbo_x_off, src_fbo_y_off;
|
||||
|
||||
if (!glamor_priv->has_fbo_blit) {
|
||||
glamor_delayed_fallback(screen,
|
||||
"no EXT_framebuffer_blit\n");
|
||||
glamor_delayed_fallback(screen, "no EXT_framebuffer_blit\n");
|
||||
return FALSE;
|
||||
}
|
||||
src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
|
||||
|
@ -77,10 +75,8 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
|
|||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT,
|
||||
src_pixmap_priv->base.fbo->fb);
|
||||
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off,
|
||||
&dst_y_off);
|
||||
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off,
|
||||
&src_y_off);
|
||||
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
|
||||
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off, &src_y_off);
|
||||
dst_x_off += fbo_x_off;
|
||||
dst_y_off += fbo_y_off;
|
||||
src_y_off += dy + src_fbo_y_off;
|
||||
|
@ -104,21 +100,17 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
|
|||
dst_x_off),
|
||||
(box[i].y2 +
|
||||
dst_y_off),
|
||||
GL_COLOR_BUFFER_BIT,
|
||||
GL_NEAREST);
|
||||
} else {
|
||||
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
}
|
||||
else {
|
||||
int flip_dst_y1 =
|
||||
dst_pixmap->drawable.height - (box[i].y2 +
|
||||
dst_y_off);
|
||||
dst_pixmap->drawable.height - (box[i].y2 + dst_y_off);
|
||||
int flip_dst_y2 =
|
||||
dst_pixmap->drawable.height - (box[i].y1 +
|
||||
dst_y_off);
|
||||
dst_pixmap->drawable.height - (box[i].y1 + dst_y_off);
|
||||
int flip_src_y1 =
|
||||
src_pixmap->drawable.height - (box[i].y2 +
|
||||
src_y_off);
|
||||
src_pixmap->drawable.height - (box[i].y2 + src_y_off);
|
||||
int flip_src_y2 =
|
||||
src_pixmap->drawable.height - (box[i].y1 +
|
||||
src_y_off);
|
||||
src_pixmap->drawable.height - (box[i].y1 + src_y_off);
|
||||
|
||||
dispatch->glBlitFramebuffer(box[i].x1 + dx +
|
||||
src_x_off,
|
||||
|
@ -132,8 +124,7 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
|
|||
box[i].x2 +
|
||||
dst_x_off,
|
||||
flip_dst_y2,
|
||||
GL_COLOR_BUFFER_BIT,
|
||||
GL_NEAREST);
|
||||
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
}
|
||||
}
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
|
@ -176,54 +167,40 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
pixmap_priv_get_dest_scale(dst_pixmap_priv, &dst_xscale, &dst_yscale);
|
||||
pixmap_priv_get_scale(src_pixmap_priv, &src_xscale, &src_yscale);
|
||||
|
||||
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off,
|
||||
&dst_y_off);
|
||||
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
|
||||
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
|
||||
|
||||
glamor_set_destination_pixmap_priv_nc(dst_pixmap_priv);
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
vertices);
|
||||
GL_FALSE, 2 * sizeof(float), vertices);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
|
||||
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off,
|
||||
&src_y_off);
|
||||
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off, &src_y_off);
|
||||
dx += src_x_off;
|
||||
dy += src_y_off;
|
||||
|
||||
dispatch->glActiveTexture(GL_TEXTURE0);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D,
|
||||
src_pixmap_priv->base.fbo->tex);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv->base.fbo->tex);
|
||||
#ifndef GLAMOR_GLES2
|
||||
dispatch->glEnable(GL_TEXTURE_2D);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_S,
|
||||
GL_CLAMP_TO_BORDER);
|
||||
GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_T,
|
||||
GL_CLAMP_TO_BORDER);
|
||||
GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
|
||||
#endif
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MIN_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MAG_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
|
||||
GL_FLOAT, GL_FALSE,
|
||||
2 * sizeof(float),
|
||||
texcoords);
|
||||
2 * sizeof(float), texcoords);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
dispatch->glUseProgram(glamor_priv->finish_access_prog[0]);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_revert[0],
|
||||
REVERT_NONE);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_revert[0], REVERT_NONE);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[0],
|
||||
SWAP_NONE_UPLOADING);
|
||||
|
||||
|
@ -235,8 +212,7 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
|
|||
box[i].y1 + dst_y_off,
|
||||
box[i].x2 + dst_x_off,
|
||||
box[i].y2 + dst_y_off,
|
||||
glamor_priv->yInverted,
|
||||
vertices);
|
||||
glamor_priv->yInverted, vertices);
|
||||
|
||||
glamor_set_normalize_tcoords(src_pixmap_priv,
|
||||
src_xscale,
|
||||
|
@ -245,8 +221,7 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
|
|||
box[i].y1 + dy,
|
||||
box[i].x2 + dx,
|
||||
box[i].y2 + dy,
|
||||
glamor_priv->yInverted,
|
||||
texcoords);
|
||||
glamor_priv->yInverted, texcoords);
|
||||
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
}
|
||||
|
||||
|
@ -272,8 +247,7 @@ __glamor_copy_n_to_n(DrawablePtr src,
|
|||
int dx,
|
||||
int dy,
|
||||
Bool reverse,
|
||||
Bool upsidedown, Pixel bitplane,
|
||||
void *closure)
|
||||
Bool upsidedown, Pixel bitplane, void *closure)
|
||||
{
|
||||
PixmapPtr dst_pixmap, src_pixmap, temp_pixmap = NULL;
|
||||
DrawablePtr temp_src = src;
|
||||
|
@ -294,16 +268,15 @@ __glamor_copy_n_to_n(DrawablePtr src,
|
|||
src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
|
||||
screen = dst_pixmap->drawable.pScreen;
|
||||
glamor_priv = glamor_get_screen_private(dst->pScreen);
|
||||
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off,
|
||||
&src_y_off);
|
||||
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off, &src_y_off);
|
||||
|
||||
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off,
|
||||
&dst_y_off);
|
||||
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
|
||||
|
||||
if (src_pixmap_priv->base.fbo
|
||||
&& src_pixmap_priv->base.fbo->fb == dst_pixmap_priv->base.fbo->fb) {
|
||||
int x_shift = abs(src_x_off - dx - dst_x_off);
|
||||
int y_shift = abs(src_y_off - dy - dst_y_off);
|
||||
|
||||
for (i = 0; i < nbox; i++) {
|
||||
if (x_shift < abs(box[i].x2 - box[i].x1)
|
||||
&& y_shift < abs(box[i].y2 - box[i].y1)) {
|
||||
|
@ -315,14 +288,12 @@ __glamor_copy_n_to_n(DrawablePtr src,
|
|||
DEBUGF("Copy %d %d %dx%d dx %d dy %d from %p to %p \n",
|
||||
box[0].x1, box[0].y1,
|
||||
box[0].x2 - box[0].x1, box[0].y2 - box[0].y1,
|
||||
dx, dy,
|
||||
src_pixmap, dst_pixmap);
|
||||
dx, dy, src_pixmap, dst_pixmap);
|
||||
#ifndef GLAMOR_GLES2
|
||||
if (!overlaped &&
|
||||
(glamor_priv->state != RENDER_STATE
|
||||
|| !src_pixmap_priv->base.gl_tex || !dst_pixmap_priv->base.gl_tex)
|
||||
&& glamor_copy_n_to_n_fbo_blit(src, dst, gc, box, nbox, dx,
|
||||
dy)) {
|
||||
&& glamor_copy_n_to_n_fbo_blit(src, dst, gc, box, nbox, dx, dy)) {
|
||||
ret = TRUE;
|
||||
goto done;
|
||||
}
|
||||
|
@ -337,13 +308,13 @@ __glamor_copy_n_to_n(DrawablePtr src,
|
|||
src_pixmap->drawable.height)
|
||||
|| !(glamor_check_fbo_size(glamor_priv,
|
||||
src_pixmap->drawable.width,
|
||||
src_pixmap->drawable.height))))) {
|
||||
src_pixmap->drawable.
|
||||
height))))) {
|
||||
|
||||
temp_pixmap = glamor_create_pixmap(screen,
|
||||
bound.x2 - bound.x1,
|
||||
bound.y2 - bound.y1,
|
||||
src_pixmap->
|
||||
drawable.depth,
|
||||
src_pixmap->drawable.depth,
|
||||
overlaped ? 0 :
|
||||
GLAMOR_CREATE_PIXMAP_CPU);
|
||||
assert(bound.x2 - bound.x1 <= glamor_priv->max_fbo_size);
|
||||
|
@ -356,8 +327,7 @@ __glamor_copy_n_to_n(DrawablePtr src,
|
|||
if (overlaped)
|
||||
glamor_copy_n_to_n_textured(src, temp_src, gc, box,
|
||||
nbox,
|
||||
temp_dx + bound.x1,
|
||||
temp_dy + bound.y1);
|
||||
temp_dx + bound.x1, temp_dy + bound.y1);
|
||||
else
|
||||
fbCopyNtoN(src, temp_src, gc, box, nbox,
|
||||
temp_dx + bound.x1, temp_dy + bound.y1,
|
||||
|
@ -365,7 +335,8 @@ __glamor_copy_n_to_n(DrawablePtr src,
|
|||
glamor_translate_boxes(box, nbox, bound.x1, bound.y1);
|
||||
temp_dx = -bound.x1;
|
||||
temp_dy = -bound.y1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
temp_dx = dx;
|
||||
temp_dy = dy;
|
||||
temp_src = src;
|
||||
|
@ -375,7 +346,7 @@ __glamor_copy_n_to_n(DrawablePtr src,
|
|||
(temp_src, dst, gc, box, nbox, temp_dx, temp_dy)) {
|
||||
ret = TRUE;
|
||||
}
|
||||
done:
|
||||
done:
|
||||
if (temp_src != src)
|
||||
glamor_destroy_pixmap(temp_pixmap);
|
||||
return ret;
|
||||
|
@ -415,8 +386,7 @@ _glamor_copy_n_to_n(DrawablePtr src,
|
|||
DEBUGF("Copy %d %d %dx%d dx %d dy %d from %p to %p \n",
|
||||
box[0].x1, box[0].y1,
|
||||
box[0].x2 - box[0].x1, box[0].y2 - box[0].y1,
|
||||
dx, dy,
|
||||
src_pixmap, dst_pixmap);
|
||||
dx, dy, src_pixmap, dst_pixmap);
|
||||
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dst_pixmap_priv))
|
||||
goto fall_back;
|
||||
|
@ -437,10 +407,8 @@ _glamor_copy_n_to_n(DrawablePtr src,
|
|||
src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
|
||||
}
|
||||
|
||||
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off,
|
||||
&src_y_off);
|
||||
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off,
|
||||
&dst_y_off);
|
||||
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off, &src_y_off);
|
||||
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
|
||||
|
||||
RegionInitBoxes(®ion, box, nbox);
|
||||
extent = RegionExtents(®ion);
|
||||
|
@ -461,82 +429,101 @@ _glamor_copy_n_to_n(DrawablePtr src,
|
|||
|
||||
RegionTranslate(®ion, dst_x_off, dst_y_off);
|
||||
if (!force_clip)
|
||||
clipped_dst_regions = glamor_compute_clipped_regions(dst_pixmap_priv,
|
||||
®ion, &n_dst_region, 0,
|
||||
reverse, upsidedown);
|
||||
clipped_dst_regions =
|
||||
glamor_compute_clipped_regions(dst_pixmap_priv, ®ion,
|
||||
&n_dst_region, 0, reverse,
|
||||
upsidedown);
|
||||
else
|
||||
clipped_dst_regions = glamor_compute_clipped_regions_ext(dst_pixmap_priv,
|
||||
®ion, &n_dst_region,
|
||||
clipped_dst_regions =
|
||||
glamor_compute_clipped_regions_ext(dst_pixmap_priv, ®ion,
|
||||
&n_dst_region,
|
||||
glamor_priv->max_fbo_size,
|
||||
glamor_priv->max_fbo_size,
|
||||
reverse, upsidedown);
|
||||
for(i = 0; i < n_dst_region; i++)
|
||||
{
|
||||
for (i = 0; i < n_dst_region; i++) {
|
||||
int n_src_region;
|
||||
glamor_pixmap_clipped_regions *clipped_src_regions;
|
||||
BoxPtr current_boxes;
|
||||
int n_current_boxes;
|
||||
|
||||
SET_PIXMAP_FBO_CURRENT(dst_pixmap_priv, clipped_dst_regions[i].block_idx);
|
||||
SET_PIXMAP_FBO_CURRENT(dst_pixmap_priv,
|
||||
clipped_dst_regions[i].block_idx);
|
||||
|
||||
temp_source_pixmap = NULL;
|
||||
if (src_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
RegionTranslate(clipped_dst_regions[i].region,
|
||||
-dst_x_off + src_x_off + dx, -dst_y_off + src_y_off + dy);
|
||||
clipped_src_regions = glamor_compute_clipped_regions(src_pixmap_priv,
|
||||
clipped_dst_regions[i].region,
|
||||
&n_src_region, 0,
|
||||
-dst_x_off + src_x_off + dx,
|
||||
-dst_y_off + src_y_off + dy);
|
||||
clipped_src_regions =
|
||||
glamor_compute_clipped_regions(src_pixmap_priv,
|
||||
clipped_dst_regions[i].
|
||||
region, &n_src_region, 0,
|
||||
reverse, upsidedown);
|
||||
DEBUGF("Source is large pixmap.\n");
|
||||
for (j = 0; j < n_src_region; j++)
|
||||
{
|
||||
for (j = 0; j < n_src_region; j++) {
|
||||
if (src_pixmap_priv != dst_pixmap_priv)
|
||||
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);
|
||||
else if (src_pixmap_priv == dst_pixmap_priv &&
|
||||
clipped_src_regions[j].block_idx != clipped_dst_regions[i].block_idx) {
|
||||
clipped_src_regions[j].block_idx !=
|
||||
clipped_dst_regions[i].block_idx) {
|
||||
/* source and the dest are the same, but need different block_idx.
|
||||
* we create a empty pixmap and fill the required source fbo and box to
|
||||
* it. It's a little hacky, but avoid extra copy. */
|
||||
temp_source_pixmap = glamor_create_pixmap(src->pScreen, 0, 0,
|
||||
src->depth, 0);
|
||||
temp_source_pixmap =
|
||||
glamor_create_pixmap(src->pScreen, 0, 0, src->depth,
|
||||
0);
|
||||
if (!temp_source_pixmap) {
|
||||
ok = FALSE;
|
||||
goto fail;
|
||||
}
|
||||
src->pScreen->ModifyPixmapHeader(temp_source_pixmap,
|
||||
src_pixmap->drawable.width,
|
||||
src_pixmap->drawable.height,
|
||||
0, 0, src_pixmap->devKind, NULL);
|
||||
temp_source_priv = glamor_get_pixmap_private(temp_source_pixmap);
|
||||
src_pixmap->drawable.
|
||||
width,
|
||||
src_pixmap->drawable.
|
||||
height, 0, 0,
|
||||
src_pixmap->devKind,
|
||||
NULL);
|
||||
temp_source_priv =
|
||||
glamor_get_pixmap_private(temp_source_pixmap);
|
||||
*temp_source_priv = *src_pixmap_priv;
|
||||
temp_source_priv->large.box = src_pixmap_priv->large.box_array[clipped_src_regions[j].block_idx];
|
||||
temp_source_priv->base.fbo = src_pixmap_priv->large.fbo_array[clipped_src_regions[j].block_idx];
|
||||
temp_source_priv->large.box =
|
||||
src_pixmap_priv->large.
|
||||
box_array[clipped_src_regions[j].block_idx];
|
||||
temp_source_priv->base.fbo =
|
||||
src_pixmap_priv->large.
|
||||
fbo_array[clipped_src_regions[j].block_idx];
|
||||
temp_source_priv->base.pixmap = temp_source_pixmap;
|
||||
}
|
||||
assert(temp_source_pixmap || !(src_pixmap_priv == dst_pixmap_priv
|
||||
&& (clipped_src_regions[j].block_idx != clipped_dst_regions[i].block_idx)));
|
||||
assert(temp_source_pixmap ||
|
||||
!(src_pixmap_priv == dst_pixmap_priv &&
|
||||
(clipped_src_regions[j].block_idx !=
|
||||
clipped_dst_regions[i].block_idx)));
|
||||
|
||||
RegionTranslate(clipped_src_regions[j].region,
|
||||
-src_x_off - dx,
|
||||
-src_y_off - dy);
|
||||
-src_x_off - dx, -src_y_off - dy);
|
||||
current_boxes = RegionRects(clipped_src_regions[j].region);
|
||||
n_current_boxes = RegionNumRects(clipped_src_regions[j].region);
|
||||
n_current_boxes =
|
||||
RegionNumRects(clipped_src_regions[j].region);
|
||||
DEBUGF("dst pixmap fbo idx %d src pixmap fbo idx %d \n",
|
||||
clipped_dst_regions[i].block_idx,
|
||||
clipped_src_regions[j].block_idx);
|
||||
DEBUGF("Copy %d %d %d %d dx %d dy %d from %p to %p \n",
|
||||
current_boxes[0].x1, current_boxes[0].y1,
|
||||
current_boxes[0].x2, current_boxes[0].y2,
|
||||
dx, dy, src_pixmap, dst_pixmap);
|
||||
current_boxes[0].x2, current_boxes[0].y2, dx, dy,
|
||||
src_pixmap, dst_pixmap);
|
||||
if (!temp_source_pixmap)
|
||||
ok = __glamor_copy_n_to_n(src, dst, gc, current_boxes,
|
||||
n_current_boxes, dx, dy, reverse,
|
||||
upsidedown, bitplane, closure);
|
||||
n_current_boxes, dx, dy,
|
||||
reverse, upsidedown, bitplane,
|
||||
closure);
|
||||
else {
|
||||
ok = __glamor_copy_n_to_n(&temp_source_pixmap->drawable,
|
||||
dst, gc, current_boxes,
|
||||
n_current_boxes, dx, dy, reverse,
|
||||
upsidedown, bitplane, closure);
|
||||
n_current_boxes, dx, dy,
|
||||
reverse, upsidedown, bitplane,
|
||||
closure);
|
||||
temp_source_priv->type = GLAMOR_MEMORY;
|
||||
temp_source_priv->base.fbo = NULL;
|
||||
glamor_destroy_pixmap(temp_source_pixmap);
|
||||
|
@ -553,10 +540,10 @@ _glamor_copy_n_to_n(DrawablePtr src,
|
|||
if (n_src_region == 0)
|
||||
ok = TRUE;
|
||||
free(clipped_src_regions);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
RegionTranslate(clipped_dst_regions[i].region,
|
||||
- dst_x_off,
|
||||
- dst_y_off);
|
||||
-dst_x_off, -dst_y_off);
|
||||
current_boxes = RegionRects(clipped_dst_regions[i].region);
|
||||
n_current_boxes = RegionNumRects(clipped_dst_regions[i].region);
|
||||
|
||||
|
@ -578,22 +565,21 @@ _glamor_copy_n_to_n(DrawablePtr src,
|
|||
ok = TRUE;
|
||||
free(clipped_dst_regions);
|
||||
RegionUninit(®ion);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ok = __glamor_copy_n_to_n(src, dst, gc, box, nbox, dx, dy,
|
||||
reverse, upsidedown, bitplane,
|
||||
closure);
|
||||
reverse, upsidedown, bitplane, closure);
|
||||
}
|
||||
|
||||
fail:
|
||||
fail:
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
glamor_set_alu(dispatch, GXcopy);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
|
||||
if (ok)
|
||||
return TRUE;
|
||||
fall_back:
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(src)
|
||||
fall_back:
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(src)
|
||||
&& glamor_ddx_fallback_check_pixmap(dst))
|
||||
goto done;
|
||||
|
||||
|
@ -611,11 +597,9 @@ fall_back:
|
|||
glamor_get_drawable_location(dst));
|
||||
|
||||
if (glamor_prepare_access(dst, GLAMOR_ACCESS_RW)) {
|
||||
if (dst == src
|
||||
|| glamor_prepare_access(src, GLAMOR_ACCESS_RO)) {
|
||||
if (dst == src || glamor_prepare_access(src, GLAMOR_ACCESS_RO)) {
|
||||
fbCopyNtoN(src, dst, gc, box, nbox,
|
||||
dx, dy, reverse, upsidedown, bitplane,
|
||||
closure);
|
||||
dx, dy, reverse, upsidedown, bitplane, closure);
|
||||
if (dst != src)
|
||||
glamor_finish_access(src, GLAMOR_ACCESS_RO);
|
||||
}
|
||||
|
@ -631,10 +615,10 @@ fall_back:
|
|||
|
||||
RegionPtr
|
||||
glamor_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc,
|
||||
int srcx, int srcy, int width, int height, int dstx,
|
||||
int dsty)
|
||||
int srcx, int srcy, int width, int height, int dstx, int dsty)
|
||||
{
|
||||
RegionPtr region;
|
||||
|
||||
region = miDoCopy(src, dst, gc,
|
||||
srcx, srcy, width, height,
|
||||
dstx, dsty, glamor_copy_n_to_n, 0, NULL);
|
||||
|
@ -650,9 +634,7 @@ glamor_copy_n_to_n(DrawablePtr src,
|
|||
int nbox,
|
||||
int dx,
|
||||
int dy,
|
||||
Bool reverse,
|
||||
Bool upsidedown, Pixel bitplane,
|
||||
void *closure)
|
||||
Bool reverse, Bool upsidedown, Pixel bitplane, void *closure)
|
||||
{
|
||||
_glamor_copy_n_to_n(src, dst, gc, box, nbox, dx,
|
||||
dy, reverse, upsidedown, bitplane, closure, TRUE);
|
||||
|
@ -667,10 +649,9 @@ glamor_copy_n_to_n_nf(DrawablePtr src,
|
|||
int dx,
|
||||
int dy,
|
||||
Bool reverse,
|
||||
Bool upsidedown, Pixel bitplane,
|
||||
void *closure)
|
||||
Bool upsidedown, Pixel bitplane, void *closure)
|
||||
{
|
||||
return _glamor_copy_n_to_n(src, dst, gc, box, nbox, dx,
|
||||
dy, reverse, upsidedown, bitplane, closure, FALSE);
|
||||
dy, reverse, upsidedown, bitplane, closure,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,7 @@ _glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
|
|||
int srcx, int srcy, int w, int h, int dstx, int dsty,
|
||||
unsigned long bitPlane, RegionPtr *pRegion, Bool fallback)
|
||||
{
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_gc(pGC)
|
||||
if (!fallback && glamor_ddx_fallback_check_gc(pGC)
|
||||
&& glamor_ddx_fallback_check_pixmap(pSrc)
|
||||
&& glamor_ddx_fallback_check_pixmap(pDst))
|
||||
goto fail;
|
||||
|
@ -57,6 +56,7 @@ glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
|
|||
unsigned long bitPlane)
|
||||
{
|
||||
RegionPtr ret;
|
||||
|
||||
_glamor_copy_plane(pSrc, pDst, pGC, srcx, srcy, w, h,
|
||||
dstx, dsty, bitPlane, &ret, TRUE);
|
||||
return ret;
|
||||
|
|
|
@ -29,8 +29,7 @@
|
|||
*/
|
||||
|
||||
void
|
||||
glamor_copy_window(WindowPtr win, DDXPointRec old_origin,
|
||||
RegionPtr src_region)
|
||||
glamor_copy_window(WindowPtr win, DDXPointRec old_origin, RegionPtr src_region)
|
||||
{
|
||||
RegionRec dst_region;
|
||||
int dx, dy;
|
||||
|
@ -51,8 +50,7 @@ glamor_copy_window(WindowPtr win, DDXPointRec old_origin,
|
|||
#endif
|
||||
|
||||
miCopyRegion(&pixmap->drawable, &pixmap->drawable,
|
||||
NULL, &dst_region, dx, dy, glamor_copy_n_to_n, 0,
|
||||
NULL);
|
||||
NULL, &dst_region, dx, dy, glamor_copy_n_to_n, 0, NULL);
|
||||
|
||||
REGION_UNINIT(win->drawable.pScreen, &dst_region);
|
||||
}
|
||||
|
|
|
@ -39,8 +39,7 @@ const Bool
|
|||
glamor_get_drawable_location(const DrawablePtr drawable)
|
||||
{
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(drawable->pScreen);
|
||||
if (pixmap_priv == NULL || pixmap_priv->base.gl_fbo == 0)
|
||||
|
@ -74,7 +73,8 @@ glamor_compile_glsl_prog(glamor_gl_dispatch * dispatch, GLenum type,
|
|||
type == GL_FRAGMENT_SHADER ? "FS" : "VS", info);
|
||||
ErrorF("Program source:\n%s", source);
|
||||
free(info);
|
||||
} else
|
||||
}
|
||||
else
|
||||
ErrorF("Failed to get shader compilation info.\n");
|
||||
FatalError("GLSL compile failure\n");
|
||||
}
|
||||
|
@ -102,11 +102,11 @@ glamor_link_glsl_prog(glamor_gl_dispatch * dispatch, GLint prog)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
Bool
|
||||
glamor_prepare_access(DrawablePtr drawable, glamor_access_t access)
|
||||
{
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
|
||||
return glamor_download_pixmap_to_cpu(pixmap, access);
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,8 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
|
|||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = v_position;\n"
|
||||
" source_texture = v_texcoord0.xy;\n" "}\n";
|
||||
" source_texture = v_texcoord0.xy;\n"
|
||||
"}\n";
|
||||
|
||||
const char *common_source =
|
||||
GLAMOR_DEFAULT_PRECISION
|
||||
|
@ -159,7 +160,6 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
|
|||
"uniform sampler2D sampler;\n"
|
||||
"uniform int revert;\n"
|
||||
"uniform int swap_rb;\n"
|
||||
|
||||
"#define REVERT_NONE 0\n"
|
||||
"#define REVERT_NORMAL 1\n"
|
||||
"#define SWAP_NONE_DOWNLOADING 0\n"
|
||||
|
@ -187,7 +187,8 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
|
|||
" 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";
|
||||
" } \n"
|
||||
"}\n";
|
||||
|
||||
const char *set_alpha_source =
|
||||
"void main()\n"
|
||||
|
@ -220,60 +221,47 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
|
|||
glamor_priv->finish_access_prog[0] = dispatch->glCreateProgram();
|
||||
glamor_priv->finish_access_prog[1] = dispatch->glCreateProgram();
|
||||
|
||||
vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER,
|
||||
vs_source);
|
||||
vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, vs_source);
|
||||
|
||||
XNFasprintf(&source, "%s%s", common_source, fs_source);
|
||||
fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
|
||||
source);
|
||||
fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER, source);
|
||||
free(source);
|
||||
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[0],
|
||||
vs_prog);
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[0],
|
||||
fs_prog);
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[0], vs_prog);
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[0], fs_prog);
|
||||
|
||||
avs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER,
|
||||
vs_source);
|
||||
avs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, vs_source);
|
||||
|
||||
XNFasprintf(&source, "%s%s", common_source, set_alpha_source);
|
||||
set_alpha_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
|
||||
source);
|
||||
free(source);
|
||||
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[1],
|
||||
avs_prog);
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[1], avs_prog);
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[1],
|
||||
set_alpha_prog);
|
||||
|
||||
dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[0],
|
||||
GLAMOR_VERTEX_POS, "v_position");
|
||||
dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[0],
|
||||
GLAMOR_VERTEX_SOURCE,
|
||||
"v_texcoord0");
|
||||
glamor_link_glsl_prog(dispatch,
|
||||
glamor_priv->finish_access_prog[0]);
|
||||
GLAMOR_VERTEX_SOURCE, "v_texcoord0");
|
||||
glamor_link_glsl_prog(dispatch, glamor_priv->finish_access_prog[0]);
|
||||
|
||||
dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[1],
|
||||
GLAMOR_VERTEX_POS, "v_position");
|
||||
dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[1],
|
||||
GLAMOR_VERTEX_SOURCE,
|
||||
"v_texcoord0");
|
||||
glamor_link_glsl_prog(dispatch,
|
||||
glamor_priv->finish_access_prog[1]);
|
||||
GLAMOR_VERTEX_SOURCE, "v_texcoord0");
|
||||
glamor_link_glsl_prog(dispatch, glamor_priv->finish_access_prog[1]);
|
||||
|
||||
glamor_priv->finish_access_revert[0] =
|
||||
dispatch->
|
||||
glGetUniformLocation(glamor_priv->finish_access_prog[0],
|
||||
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[0],
|
||||
"revert");
|
||||
|
||||
glamor_priv->finish_access_swap_rb[0] =
|
||||
dispatch->
|
||||
glGetUniformLocation(glamor_priv->finish_access_prog[0],
|
||||
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[0],
|
||||
"swap_rb");
|
||||
sampler_uniform_location =
|
||||
dispatch->
|
||||
glGetUniformLocation(glamor_priv->finish_access_prog[0],
|
||||
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[0],
|
||||
"sampler");
|
||||
dispatch->glUseProgram(glamor_priv->finish_access_prog[0]);
|
||||
dispatch->glUniform1i(sampler_uniform_location, 0);
|
||||
|
@ -282,16 +270,13 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
|
|||
dispatch->glUseProgram(0);
|
||||
|
||||
glamor_priv->finish_access_revert[1] =
|
||||
dispatch->
|
||||
glGetUniformLocation(glamor_priv->finish_access_prog[1],
|
||||
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[1],
|
||||
"revert");
|
||||
glamor_priv->finish_access_swap_rb[1] =
|
||||
dispatch->
|
||||
glGetUniformLocation(glamor_priv->finish_access_prog[1],
|
||||
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[1],
|
||||
"swap_rb");
|
||||
sampler_uniform_location =
|
||||
dispatch->
|
||||
glGetUniformLocation(glamor_priv->finish_access_prog[1],
|
||||
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);
|
||||
|
@ -318,8 +303,7 @@ void
|
|||
glamor_finish_access(DrawablePtr drawable, glamor_access_t access_mode)
|
||||
{
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(drawable->pScreen);
|
||||
|
||||
|
@ -343,7 +327,8 @@ glamor_finish_access(DrawablePtr drawable, glamor_access_t access_mode)
|
|||
|
||||
pixmap_priv->base.fbo->pbo_valid = FALSE;
|
||||
pixmap_priv->base.fbo->pbo = 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
free(pixmap->devPrivate.ptr);
|
||||
}
|
||||
|
||||
|
@ -356,7 +341,6 @@ glamor_finish_access(DrawablePtr drawable, glamor_access_t access_mode)
|
|||
pixmap->devPrivate.ptr = NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calls uxa_prepare_access with UXA_PREPARE_SRC for the tile, if that is the
|
||||
* current fill style.
|
||||
|
@ -369,17 +353,14 @@ Bool
|
|||
glamor_prepare_access_gc(GCPtr gc)
|
||||
{
|
||||
if (gc->stipple) {
|
||||
if (!glamor_prepare_access
|
||||
(&gc->stipple->drawable, GLAMOR_ACCESS_RO))
|
||||
if (!glamor_prepare_access(&gc->stipple->drawable, GLAMOR_ACCESS_RO))
|
||||
return FALSE;
|
||||
}
|
||||
if (gc->fillStyle == FillTiled) {
|
||||
if (!glamor_prepare_access(&gc->tile.pixmap->drawable,
|
||||
GLAMOR_ACCESS_RO)) {
|
||||
if (gc->stipple)
|
||||
glamor_finish_access(&gc->
|
||||
stipple->drawable,
|
||||
GLAMOR_ACCESS_RO);
|
||||
glamor_finish_access(&gc->stipple->drawable, GLAMOR_ACCESS_RO);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -405,8 +386,7 @@ glamor_stipple(PixmapPtr pixmap, PixmapPtr stipple,
|
|||
unsigned long fg_pixel, unsigned long bg_pixel,
|
||||
int stipple_x, int stipple_y)
|
||||
{
|
||||
glamor_fallback("stubbed out stipple depth %d\n",
|
||||
pixmap->drawable.depth);
|
||||
glamor_fallback("stubbed out stipple depth %d\n", pixmap->drawable.depth);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -454,31 +434,23 @@ glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable)
|
|||
PixmapPtr old_tile, new_tile;
|
||||
|
||||
old_tile = gc->tile.pixmap;
|
||||
if (old_tile->drawable.bitsPerPixel !=
|
||||
drawable->bitsPerPixel) {
|
||||
if (old_tile->drawable.bitsPerPixel != drawable->bitsPerPixel) {
|
||||
new_tile = fbGetRotatedPixmap(gc);
|
||||
if (!new_tile ||
|
||||
new_tile->drawable.bitsPerPixel !=
|
||||
drawable->bitsPerPixel) {
|
||||
new_tile->drawable.bitsPerPixel != drawable->bitsPerPixel) {
|
||||
if (new_tile)
|
||||
gc->pScreen->DestroyPixmap
|
||||
(new_tile);
|
||||
gc->pScreen->DestroyPixmap(new_tile);
|
||||
/* fb24_32ReformatTile will do direct access of a newly-
|
||||
* allocated pixmap.
|
||||
*/
|
||||
glamor_fallback
|
||||
("GC %p tile FB_24_32 transformat %p.\n",
|
||||
gc, old_tile);
|
||||
("GC %p tile FB_24_32 transformat %p.\n", gc, old_tile);
|
||||
|
||||
if (glamor_prepare_access
|
||||
(&old_tile->drawable,
|
||||
GLAMOR_ACCESS_RO)) {
|
||||
(&old_tile->drawable, GLAMOR_ACCESS_RO)) {
|
||||
new_tile =
|
||||
fb24_32ReformatTile
|
||||
(old_tile,
|
||||
drawable->bitsPerPixel);
|
||||
glamor_finish_access
|
||||
(&old_tile->drawable, GLAMOR_ACCESS_RO);
|
||||
fb24_32ReformatTile(old_tile, drawable->bitsPerPixel);
|
||||
glamor_finish_access(&old_tile->drawable, GLAMOR_ACCESS_RO);
|
||||
}
|
||||
}
|
||||
if (new_tile) {
|
||||
|
@ -497,11 +469,9 @@ glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable)
|
|||
&& FbEvenTile(gc->tile.pixmap->drawable.width *
|
||||
drawable->bitsPerPixel)) {
|
||||
glamor_fallback
|
||||
("GC %p tile changed %p.\n", gc,
|
||||
gc->tile.pixmap);
|
||||
("GC %p tile changed %p.\n", gc, gc->tile.pixmap);
|
||||
if (glamor_prepare_access
|
||||
(&gc->tile.pixmap->drawable,
|
||||
GLAMOR_ACCESS_RW)) {
|
||||
(&gc->tile.pixmap->drawable, GLAMOR_ACCESS_RW)) {
|
||||
fbPadPixmap(gc->tile.pixmap);
|
||||
glamor_finish_access
|
||||
(&gc->tile.pixmap->drawable, GLAMOR_ACCESS_RW);
|
||||
|
@ -518,12 +488,12 @@ glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable)
|
|||
/* We can't inline stipple handling like we do for GCTile because
|
||||
* it sets fbgc privates.
|
||||
*/
|
||||
if (glamor_prepare_access
|
||||
(&gc->stipple->drawable, GLAMOR_ACCESS_RW)) {
|
||||
if (glamor_prepare_access(&gc->stipple->drawable, GLAMOR_ACCESS_RW)) {
|
||||
fbValidateGC(gc, changes, drawable);
|
||||
glamor_finish_access(&gc->stipple->drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fbValidateGC(gc, changes, drawable);
|
||||
}
|
||||
|
||||
|
@ -559,6 +529,7 @@ RegionPtr
|
|||
glamor_bitmap_to_region(PixmapPtr pixmap)
|
||||
{
|
||||
RegionPtr ret;
|
||||
|
||||
glamor_fallback("pixmap %p \n", pixmap);
|
||||
if (!glamor_prepare_access(&pixmap->drawable, GLAMOR_ACCESS_RO))
|
||||
return NULL;
|
||||
|
@ -573,9 +544,10 @@ glamor_gl_has_extension(const char *extension)
|
|||
{
|
||||
const char *pext;
|
||||
int ext_len;
|
||||
|
||||
ext_len = strlen(extension);
|
||||
|
||||
pext = (const char*)glGetString(GL_EXTENSIONS);
|
||||
pext = (const char *) glGetString(GL_EXTENSIONS);
|
||||
|
||||
if (pext == NULL || extension == NULL)
|
||||
return FALSE;
|
||||
|
@ -600,7 +572,8 @@ glamor_gl_get_version(void)
|
|||
if (dot == NULL || dot == version || *(dot + 1) == '\0') {
|
||||
major = 0;
|
||||
minor = 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Find the start of the major version in the string */
|
||||
while (major_start > version && *major_start != ' ')
|
||||
--major_start;
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#ifndef __GLAMOR_DEBUG_H__
|
||||
#define __GLAMOR_DEBUG_H__
|
||||
|
||||
|
||||
#define GLAMOR_DELAYED_STRING_MAX 64
|
||||
|
||||
#define GLAMOR_DEBUG_NONE 0
|
||||
|
@ -51,9 +50,6 @@ AbortServer(void)
|
|||
exit(1); \
|
||||
} while(0)
|
||||
|
||||
|
||||
|
||||
|
||||
#define __debug_output_message(_format_, _prefix_, ...) \
|
||||
LogMessageVerb(X_NONE, 0, \
|
||||
"%32s:\t" _format_ , \
|
||||
|
@ -69,7 +65,6 @@ AbortServer(void)
|
|||
##__VA_ARGS__); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define glamor_fallback(_format_,...) \
|
||||
do { \
|
||||
if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) \
|
||||
|
@ -77,8 +72,6 @@ AbortServer(void)
|
|||
"Glamor fallback", \
|
||||
##__VA_ARGS__);} while(0)
|
||||
|
||||
|
||||
|
||||
#define glamor_delayed_fallback(_screen_, _format_,...) \
|
||||
do { \
|
||||
if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) { \
|
||||
|
@ -90,7 +83,6 @@ AbortServer(void)
|
|||
"glamor delayed fallback: \t%s " _format_ , \
|
||||
__FUNCTION__, ##__VA_ARGS__); } } while(0)
|
||||
|
||||
|
||||
#define glamor_clear_delayed_fallbacks(_screen_) \
|
||||
do { \
|
||||
if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) { \
|
||||
|
@ -112,5 +104,4 @@ AbortServer(void)
|
|||
#define DEBUGRegionPrint(x) do {} while (0)
|
||||
//#define DEBUGRegionPrint RegionPrint
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -27,9 +27,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
#include "dix-config.h"
|
||||
|
||||
#define GLAMOR_FOR_XORG
|
||||
#include <xorg-server.h>
|
||||
|
@ -60,16 +58,13 @@
|
|||
#include <EGL/eglext.h>
|
||||
|
||||
#include "glamor.h"
|
||||
#include "compat-api.h"
|
||||
#include "glamor_gl_dispatch.h"
|
||||
#ifdef GLX_USE_SHARED_DISPATCH
|
||||
#include "glapi.h"
|
||||
#endif
|
||||
|
||||
static const char glamor_name[] = "glamor";
|
||||
|
||||
static DevPrivateKeyRec glamor_egl_pixmap_private_key_index;
|
||||
DevPrivateKey glamor_egl_pixmap_private_key = &glamor_egl_pixmap_private_key_index;
|
||||
DevPrivateKey glamor_egl_pixmap_private_key =
|
||||
&glamor_egl_pixmap_private_key_index;
|
||||
|
||||
static void
|
||||
glamor_identify(int flags)
|
||||
|
@ -93,8 +88,6 @@ struct glamor_egl_screen_private {
|
|||
struct gbm_device *gbm;
|
||||
#endif
|
||||
int has_gem;
|
||||
void *glamor_context;
|
||||
void *current_context;
|
||||
int gl_context_depth;
|
||||
int dri3_capable;
|
||||
|
||||
|
@ -114,7 +107,7 @@ glamor_egl_get_screen_private(ScrnInfoPtr scrn)
|
|||
return (struct glamor_egl_screen_private *)
|
||||
scrn->privates[xf86GlamorEGLPrivateIndex].ptr;
|
||||
}
|
||||
#ifdef GLX_USE_SHARED_DISPATCH
|
||||
|
||||
_X_EXPORT void
|
||||
glamor_egl_make_current(ScreenPtr screen)
|
||||
{
|
||||
|
@ -125,9 +118,7 @@ glamor_egl_make_current(ScreenPtr screen)
|
|||
if (glamor_egl->gl_context_depth++)
|
||||
return;
|
||||
|
||||
GET_CURRENT_CONTEXT(glamor_egl->current_context);
|
||||
|
||||
if (glamor_egl->glamor_context != glamor_egl->current_context) {
|
||||
if (glamor_egl->context != eglGetCurrentContext()) {
|
||||
eglMakeCurrent(glamor_egl->display, EGL_NO_SURFACE,
|
||||
EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
if (!eglMakeCurrent(glamor_egl->display,
|
||||
|
@ -148,20 +139,16 @@ glamor_egl_restore_context(ScreenPtr screen)
|
|||
if (--glamor_egl->gl_context_depth)
|
||||
return;
|
||||
|
||||
if (glamor_egl->current_context &&
|
||||
glamor_egl->glamor_context != glamor_egl->current_context)
|
||||
SET_CURRENT_CONTEXT(glamor_egl->current_context);
|
||||
eglMakeCurrent(glamor_egl->display, EGL_NO_SURFACE,
|
||||
EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
}
|
||||
#else
|
||||
#define glamor_egl_make_current(x)
|
||||
#define glamor_egl_restore_context(s)
|
||||
#endif
|
||||
|
||||
static EGLImageKHR
|
||||
_glamor_egl_create_image(struct glamor_egl_screen_private *glamor_egl,
|
||||
int width, int height, int stride, int name, int depth)
|
||||
{
|
||||
EGLImageKHR image;
|
||||
|
||||
EGLint attribs[] = {
|
||||
EGL_WIDTH, 0,
|
||||
EGL_HEIGHT, 0,
|
||||
|
@ -169,8 +156,7 @@ _glamor_egl_create_image(struct glamor_egl_screen_private *glamor_egl,
|
|||
EGL_DRM_BUFFER_FORMAT_MESA,
|
||||
EGL_DRM_BUFFER_FORMAT_ARGB32_MESA,
|
||||
EGL_DRM_BUFFER_USE_MESA,
|
||||
EGL_DRM_BUFFER_USE_SHARE_MESA |
|
||||
EGL_DRM_BUFFER_USE_SCANOUT_MESA,
|
||||
EGL_DRM_BUFFER_USE_SHARE_MESA | EGL_DRM_BUFFER_USE_SCANOUT_MESA,
|
||||
EGL_NONE
|
||||
};
|
||||
attribs[1] = width;
|
||||
|
@ -181,11 +167,11 @@ _glamor_egl_create_image(struct glamor_egl_screen_private *glamor_egl,
|
|||
image = glamor_egl->egl_create_image_khr(glamor_egl->display,
|
||||
glamor_egl->context,
|
||||
EGL_DRM_BUFFER_MESA,
|
||||
(void *) (uintptr_t)name, attribs);
|
||||
(void *) (uintptr_t) name,
|
||||
attribs);
|
||||
if (image == EGL_NO_IMAGE_KHR)
|
||||
return EGL_NO_IMAGE_KHR;
|
||||
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
|
@ -193,6 +179,7 @@ static int
|
|||
glamor_get_flink_name(int fd, int handle, int *name)
|
||||
{
|
||||
struct drm_gem_flink flink;
|
||||
|
||||
flink.handle = handle;
|
||||
if (ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink) < 0)
|
||||
return FALSE;
|
||||
|
@ -208,34 +195,30 @@ glamor_create_texture_from_image(struct glamor_egl_screen_private
|
|||
glamor_egl->dispatch->glGenTextures(1, texture);
|
||||
glamor_egl->dispatch->glBindTexture(GL_TEXTURE_2D, *texture);
|
||||
glamor_egl->dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MIN_FILTER,
|
||||
GL_NEAREST);
|
||||
GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glamor_egl->dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MAG_FILTER,
|
||||
GL_NEAREST);
|
||||
GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
(glamor_egl->egl_image_target_texture2d_oes) (GL_TEXTURE_2D,
|
||||
image);
|
||||
(glamor_egl->egl_image_target_texture2d_oes) (GL_TEXTURE_2D, image);
|
||||
glamor_egl->dispatch->glBindTexture(GL_TEXTURE_2D, 0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
glamor_egl_create_argb8888_based_texture(ScreenPtr screen,
|
||||
int w,
|
||||
int h)
|
||||
glamor_egl_create_argb8888_based_texture(ScreenPtr screen, int w, int h)
|
||||
{
|
||||
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
||||
struct glamor_egl_screen_private *glamor_egl;
|
||||
EGLImageKHR image;
|
||||
GLuint texture;
|
||||
|
||||
#ifdef GLAMOR_HAS_DRI3_SUPPORT
|
||||
struct gbm_bo *bo;
|
||||
EGLNativePixmapType native_pixmap;
|
||||
|
||||
glamor_egl = glamor_egl_get_screen_private(scrn);
|
||||
bo = gbm_bo_create (glamor_egl->gbm, w, h, GBM_FORMAT_ARGB8888,
|
||||
GBM_BO_USE_RENDERING |
|
||||
GBM_BO_USE_SCANOUT);
|
||||
bo = gbm_bo_create(glamor_egl->gbm, w, h, GBM_FORMAT_ARGB8888,
|
||||
GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT);
|
||||
if (!bo)
|
||||
return 0;
|
||||
|
||||
|
@ -272,7 +255,8 @@ glamor_egl_create_textured_screen(ScreenPtr screen, int handle, int stride)
|
|||
screen_pixmap = screen->GetScreenPixmap(screen);
|
||||
|
||||
if (!glamor_egl_create_textured_pixmap(screen_pixmap, handle, stride)) {
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to create textured screen.");
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||
"Failed to create textured screen.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -285,8 +269,7 @@ glamor_egl_create_textured_screen(ScreenPtr screen, int handle, int stride)
|
|||
Bool
|
||||
glamor_egl_create_textured_screen_ext(ScreenPtr screen,
|
||||
int handle,
|
||||
int stride,
|
||||
PixmapPtr *back_pixmap)
|
||||
int stride, PixmapPtr *back_pixmap)
|
||||
{
|
||||
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
||||
struct glamor_egl_screen_private *glamor_egl;
|
||||
|
@ -303,6 +286,7 @@ static Bool
|
|||
glamor_egl_check_has_gem(int fd)
|
||||
{
|
||||
struct drm_gem_flink flink;
|
||||
|
||||
flink.handle = 0;
|
||||
|
||||
ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink);
|
||||
|
@ -333,15 +317,16 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
|
|||
assert(0);
|
||||
return FALSE;
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
name = handle;
|
||||
|
||||
image = _glamor_egl_create_image(glamor_egl,
|
||||
pixmap->drawable.width,
|
||||
pixmap->drawable.height,
|
||||
((stride * 8 + 7) / pixmap->drawable.bitsPerPixel),
|
||||
name,
|
||||
pixmap->drawable.depth);
|
||||
((stride * 8 +
|
||||
7) / pixmap->drawable.bitsPerPixel),
|
||||
name, pixmap->drawable.depth);
|
||||
if (image == EGL_NO_IMAGE_KHR) {
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_DRM_ONLY);
|
||||
goto done;
|
||||
|
@ -349,11 +334,10 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
|
|||
glamor_create_texture_from_image(glamor_egl, image, &texture);
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
|
||||
glamor_set_pixmap_texture(pixmap, texture);
|
||||
dixSetPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key,
|
||||
image);
|
||||
dixSetPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key, image);
|
||||
ret = TRUE;
|
||||
|
||||
done:
|
||||
done:
|
||||
glamor_egl_restore_context(screen);
|
||||
return ret;
|
||||
}
|
||||
|
@ -374,8 +358,7 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo)
|
|||
|
||||
image = glamor_egl->egl_create_image_khr(glamor_egl->display,
|
||||
glamor_egl->context,
|
||||
EGL_NATIVE_PIXMAP_KHR,
|
||||
bo, NULL);
|
||||
EGL_NATIVE_PIXMAP_KHR, bo, NULL);
|
||||
if (image == EGL_NO_IMAGE_KHR) {
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_DRM_ONLY);
|
||||
goto done;
|
||||
|
@ -383,20 +366,19 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo)
|
|||
glamor_create_texture_from_image(glamor_egl, image, &texture);
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
|
||||
glamor_set_pixmap_texture(pixmap, texture);
|
||||
dixSetPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key,
|
||||
image);
|
||||
dixSetPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key, image);
|
||||
ret = TRUE;
|
||||
|
||||
done:
|
||||
done:
|
||||
glamor_egl_restore_context(screen);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef GLAMOR_HAS_DRI3_SUPPORT
|
||||
int glamor_get_fd_from_bo (int gbm_fd, struct gbm_bo *bo, int *fd);
|
||||
void glamor_get_name_from_bo (int gbm_fd, struct gbm_bo *bo, int *name);
|
||||
int glamor_get_fd_from_bo(int gbm_fd, struct gbm_bo *bo, int *fd);
|
||||
void glamor_get_name_from_bo(int gbm_fd, struct gbm_bo *bo, int *name);
|
||||
int
|
||||
glamor_get_fd_from_bo (int gbm_fd, struct gbm_bo *bo, int *fd)
|
||||
glamor_get_fd_from_bo(int gbm_fd, struct gbm_bo *bo, int *fd)
|
||||
{
|
||||
union gbm_bo_handle handle;
|
||||
struct drm_prime_handle args;
|
||||
|
@ -404,14 +386,14 @@ glamor_get_fd_from_bo (int gbm_fd, struct gbm_bo *bo, int *fd)
|
|||
handle = gbm_bo_get_handle(bo);
|
||||
args.handle = handle.u32;
|
||||
args.flags = DRM_CLOEXEC;
|
||||
if (ioctl (gbm_fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &args))
|
||||
if (ioctl(gbm_fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &args))
|
||||
return FALSE;
|
||||
*fd = args.fd;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_get_name_from_bo (int gbm_fd, struct gbm_bo *bo, int *name)
|
||||
glamor_get_name_from_bo(int gbm_fd, struct gbm_bo *bo, int *name)
|
||||
{
|
||||
union gbm_bo_handle handle;
|
||||
|
||||
|
@ -421,18 +403,17 @@ glamor_get_name_from_bo (int gbm_fd, struct gbm_bo *bo, int *name)
|
|||
}
|
||||
#endif
|
||||
|
||||
int glamor_egl_dri3_fd_name_from_tex (ScreenPtr screen,
|
||||
int
|
||||
glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
|
||||
PixmapPtr pixmap,
|
||||
unsigned int tex,
|
||||
Bool want_name,
|
||||
CARD16 *stride,
|
||||
CARD32 *size)
|
||||
Bool want_name, CARD16 *stride, CARD32 *size)
|
||||
{
|
||||
#ifdef GLAMOR_HAS_DRI3_SUPPORT
|
||||
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
||||
struct glamor_egl_screen_private *glamor_egl;
|
||||
EGLImageKHR image;
|
||||
struct gbm_bo* bo;
|
||||
struct gbm_bo *bo;
|
||||
int fd = -1;
|
||||
|
||||
EGLint attribs[] = {
|
||||
|
@ -448,18 +429,17 @@ int glamor_egl_dri3_fd_name_from_tex (ScreenPtr screen,
|
|||
image = dixLookupPrivate(&pixmap->devPrivates,
|
||||
glamor_egl_pixmap_private_key);
|
||||
|
||||
if (image == EGL_NO_IMAGE_KHR || image == NULL)
|
||||
{
|
||||
if (image == EGL_NO_IMAGE_KHR || image == NULL) {
|
||||
image = glamor_egl->egl_create_image_khr(glamor_egl->display,
|
||||
glamor_egl->context,
|
||||
EGL_GL_TEXTURE_2D_KHR,
|
||||
(EGLClientBuffer)(uintptr_t)tex, attribs);
|
||||
(EGLClientBuffer) (uintptr_t)
|
||||
tex, attribs);
|
||||
if (image == EGL_NO_IMAGE_KHR)
|
||||
goto failure;
|
||||
|
||||
dixSetPrivate(&pixmap->devPrivates,
|
||||
glamor_egl_pixmap_private_key,
|
||||
image);
|
||||
glamor_egl_pixmap_private_key, image);
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
|
||||
}
|
||||
|
||||
|
@ -469,22 +449,19 @@ int glamor_egl_dri3_fd_name_from_tex (ScreenPtr screen,
|
|||
|
||||
pixmap->devKind = gbm_bo_get_stride(bo);
|
||||
|
||||
if (want_name)
|
||||
{
|
||||
if (want_name) {
|
||||
if (glamor_egl->has_gem)
|
||||
glamor_get_name_from_bo(glamor_egl->fd, bo, &fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (glamor_get_fd_from_bo(glamor_egl->fd, bo, &fd))
|
||||
{
|
||||
else {
|
||||
if (glamor_get_fd_from_bo(glamor_egl->fd, bo, &fd)) {
|
||||
*stride = pixmap->devKind;
|
||||
*size = pixmap->devKind * gbm_bo_get_height(bo);
|
||||
}
|
||||
}
|
||||
|
||||
gbm_bo_destroy(bo);
|
||||
failure:
|
||||
failure:
|
||||
glamor_egl_restore_context(screen);
|
||||
return fd;
|
||||
#else
|
||||
|
@ -492,21 +469,21 @@ failure:
|
|||
#endif
|
||||
}
|
||||
|
||||
PixmapPtr glamor_egl_dri3_pixmap_from_fd (ScreenPtr screen,
|
||||
PixmapPtr
|
||||
glamor_egl_dri3_pixmap_from_fd(ScreenPtr screen,
|
||||
int fd,
|
||||
CARD16 width,
|
||||
CARD16 height,
|
||||
CARD16 stride,
|
||||
CARD8 depth,
|
||||
CARD8 bpp)
|
||||
CARD16 stride, CARD8 depth, CARD8 bpp)
|
||||
{
|
||||
#ifdef GLAMOR_HAS_DRI3_SUPPORT
|
||||
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
||||
struct glamor_egl_screen_private *glamor_egl;
|
||||
struct gbm_bo* bo;
|
||||
struct gbm_bo *bo;
|
||||
EGLImageKHR image;
|
||||
PixmapPtr pixmap;
|
||||
Bool ret = FALSE;
|
||||
|
||||
EGLint attribs[] = {
|
||||
EGL_WIDTH, 0,
|
||||
EGL_HEIGHT, 0,
|
||||
|
@ -547,15 +524,14 @@ PixmapPtr glamor_egl_dri3_pixmap_from_fd (ScreenPtr screen,
|
|||
return NULL;
|
||||
|
||||
pixmap = screen->CreatePixmap(screen, 0, 0, depth, 0);
|
||||
screen->ModifyPixmapHeader (pixmap, width, height, 0, 0, stride, NULL);
|
||||
screen->ModifyPixmapHeader(pixmap, width, height, 0, 0, stride, NULL);
|
||||
|
||||
ret = glamor_egl_create_textured_pixmap_from_gbm_bo(pixmap, bo);
|
||||
gbm_bo_destroy(bo);
|
||||
|
||||
if (ret)
|
||||
return pixmap;
|
||||
else
|
||||
{
|
||||
else {
|
||||
screen->DestroyPixmap(pixmap);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -580,7 +556,8 @@ _glamor_egl_destroy_pixmap_image(PixmapPtr pixmap)
|
|||
* operation on that texture has been done.*/
|
||||
glamor_block_handler(pixmap->drawable.pScreen);
|
||||
glamor_egl->egl_destroy_image_khr(glamor_egl->display, image);
|
||||
dixSetPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key, NULL);
|
||||
dixSetPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -594,10 +571,14 @@ glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr back)
|
|||
EGLImageKHR new_front_image;
|
||||
|
||||
glamor_pixmap_exchange_fbos(front, back);
|
||||
new_front_image = dixLookupPrivate(&back->devPrivates, glamor_egl_pixmap_private_key);
|
||||
old_front_image = dixLookupPrivate(&front->devPrivates, glamor_egl_pixmap_private_key);
|
||||
dixSetPrivate(&front->devPrivates, glamor_egl_pixmap_private_key, new_front_image);
|
||||
dixSetPrivate(&back->devPrivates, glamor_egl_pixmap_private_key, old_front_image);
|
||||
new_front_image =
|
||||
dixLookupPrivate(&back->devPrivates, glamor_egl_pixmap_private_key);
|
||||
old_front_image =
|
||||
dixLookupPrivate(&front->devPrivates, glamor_egl_pixmap_private_key);
|
||||
dixSetPrivate(&front->devPrivates, glamor_egl_pixmap_private_key,
|
||||
new_front_image);
|
||||
dixSetPrivate(&back->devPrivates, glamor_egl_pixmap_private_key,
|
||||
old_front_image);
|
||||
glamor_set_pixmap_type(front, GLAMOR_TEXTURE_DRM);
|
||||
glamor_set_pixmap_type(back, GLAMOR_TEXTURE_DRM);
|
||||
glamor_egl->front_image = new_front_image;
|
||||
|
@ -613,7 +594,7 @@ glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap)
|
|||
}
|
||||
|
||||
static Bool
|
||||
glamor_egl_close_screen(CLOSE_SCREEN_ARGS_DECL)
|
||||
glamor_egl_close_screen(ScreenPtr screen)
|
||||
{
|
||||
ScrnInfoPtr scrn;
|
||||
struct glamor_egl_screen_private *glamor_egl;
|
||||
|
@ -624,8 +605,10 @@ glamor_egl_close_screen(CLOSE_SCREEN_ARGS_DECL)
|
|||
glamor_egl = glamor_egl_get_screen_private(scrn);
|
||||
screen_pixmap = screen->GetScreenPixmap(screen);
|
||||
|
||||
glamor_egl->egl_destroy_image_khr(glamor_egl->display, glamor_egl->front_image);
|
||||
dixSetPrivate(&screen_pixmap->devPrivates, glamor_egl_pixmap_private_key, NULL);
|
||||
glamor_egl->egl_destroy_image_khr(glamor_egl->display,
|
||||
glamor_egl->front_image);
|
||||
dixSetPrivate(&screen_pixmap->devPrivates, glamor_egl_pixmap_private_key,
|
||||
NULL);
|
||||
glamor_egl->front_image = NULL;
|
||||
if (glamor_egl->back_pixmap && *glamor_egl->back_pixmap) {
|
||||
back_image = dixLookupPrivate(&(*glamor_egl->back_pixmap)->devPrivates,
|
||||
|
@ -639,7 +622,7 @@ glamor_egl_close_screen(CLOSE_SCREEN_ARGS_DECL)
|
|||
|
||||
screen->CloseScreen = glamor_egl->saved_close_screen;
|
||||
|
||||
return screen->CloseScreen(CLOSE_SCREEN_ARGS);
|
||||
return screen->CloseScreen(screen);
|
||||
}
|
||||
|
||||
static Bool
|
||||
|
@ -650,9 +633,7 @@ glamor_egl_has_extension(struct glamor_egl_screen_private *glamor_egl,
|
|||
int ext_len;
|
||||
|
||||
ext_len = strlen(extension);
|
||||
pext =
|
||||
(const char *) eglQueryString(glamor_egl->display,
|
||||
EGL_EXTENSIONS);
|
||||
pext = (const char *) eglQueryString(glamor_egl->display, EGL_EXTENSIONS);
|
||||
if (pext == NULL || extension == NULL)
|
||||
return FALSE;
|
||||
while ((pext = strstr(pext, extension)) != NULL) {
|
||||
|
@ -675,29 +656,22 @@ glamor_egl_screen_init(ScreenPtr screen)
|
|||
}
|
||||
|
||||
static void
|
||||
glamor_egl_free_screen(FREE_SCREEN_ARGS_DECL)
|
||||
glamor_egl_free_screen(ScrnInfoPtr scrn)
|
||||
{
|
||||
ScrnInfoPtr scrn;
|
||||
struct glamor_egl_screen_private *glamor_egl;
|
||||
#ifndef XF86_SCRN_INTERFACE
|
||||
scrn = xf86Screens[arg];
|
||||
#else
|
||||
scrn = arg;
|
||||
#endif
|
||||
|
||||
glamor_egl = glamor_egl_get_screen_private(scrn);
|
||||
if (glamor_egl != NULL) {
|
||||
|
||||
eglMakeCurrent(glamor_egl->display,
|
||||
EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
EGL_NO_CONTEXT);
|
||||
EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
#ifdef GLAMOR_HAS_GBM
|
||||
if (glamor_egl->gbm)
|
||||
gbm_device_destroy(glamor_egl->gbm);
|
||||
#endif
|
||||
scrn->FreeScreen = glamor_egl->saved_free_screen;
|
||||
free(glamor_egl);
|
||||
scrn->FreeScreen(FREE_SCREEN_ARGS);
|
||||
scrn->FreeScreen(scrn);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -706,6 +680,7 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
|||
{
|
||||
struct glamor_egl_screen_private *glamor_egl;
|
||||
const char *version;
|
||||
|
||||
EGLint config_attribs[] = {
|
||||
#ifdef GLAMOR_GLES2
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
|
@ -718,8 +693,7 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
|||
if (glamor_egl == NULL)
|
||||
return FALSE;
|
||||
if (xf86GlamorEGLPrivateIndex == -1)
|
||||
xf86GlamorEGLPrivateIndex =
|
||||
xf86AllocateScrnInfoPrivateIndex();
|
||||
xf86GlamorEGLPrivateIndex = xf86AllocateScrnInfoPrivateIndex();
|
||||
|
||||
scrn->privates[xf86GlamorEGLPrivateIndex].ptr = glamor_egl;
|
||||
glamor_egl->fd = fd;
|
||||
|
@ -731,7 +705,7 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
|||
}
|
||||
glamor_egl->display = eglGetDisplay(glamor_egl->gbm);
|
||||
#else
|
||||
glamor_egl->display = eglGetDisplay((EGLNativeDisplayType)(intptr_t)fd);
|
||||
glamor_egl->display = eglGetDisplay((EGLNativeDisplayType) (intptr_t) fd);
|
||||
#endif
|
||||
|
||||
glamor_egl->has_gem = glamor_egl_check_has_gem(fd);
|
||||
|
@ -742,10 +716,8 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
|||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
#endif
|
||||
if (!eglInitialize
|
||||
(glamor_egl->display, &glamor_egl->major, &glamor_egl->minor))
|
||||
{
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||
"eglInitialize() failed\n");
|
||||
(glamor_egl->display, &glamor_egl->major, &glamor_egl->minor)) {
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR, "eglInitialize() failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -770,12 +742,13 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
|||
#ifdef GLAMOR_GLES2
|
||||
GLAMOR_CHECK_EGL_EXTENSIONS(KHR_surfaceless_context, KHR_surfaceless_gles2);
|
||||
#else
|
||||
GLAMOR_CHECK_EGL_EXTENSIONS(KHR_surfaceless_context, KHR_surfaceless_opengl);
|
||||
GLAMOR_CHECK_EGL_EXTENSIONS(KHR_surfaceless_context,
|
||||
KHR_surfaceless_opengl);
|
||||
#endif
|
||||
|
||||
#ifdef GLAMOR_HAS_DRI3_SUPPORT
|
||||
if (glamor_egl_has_extension(glamor_egl, "EGL_KHR_gl_texture_2D_image") &&
|
||||
glamor_egl_has_extension(glamor_egl, "EGL_EXT_image_dma_buf_import") )
|
||||
glamor_egl_has_extension(glamor_egl, "EGL_EXT_image_dma_buf_import"))
|
||||
glamor_egl->dri3_capable = TRUE;
|
||||
#endif
|
||||
glamor_egl->egl_create_image_khr = (PFNEGLCREATEIMAGEKHRPROC)
|
||||
|
@ -790,8 +763,7 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
|||
|
||||
if (!glamor_egl->egl_create_image_khr
|
||||
|| !glamor_egl->egl_image_target_texture2d_oes) {
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||
"eglGetProcAddress() failed\n");
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR, "eglGetProcAddress() failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -799,29 +771,23 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
|||
NULL, EGL_NO_CONTEXT,
|
||||
config_attribs);
|
||||
if (glamor_egl->context == EGL_NO_CONTEXT) {
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||
"Failed to create EGL context\n");
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to create EGL context\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!eglMakeCurrent(glamor_egl->display,
|
||||
EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
glamor_egl->context)) {
|
||||
EGL_NO_SURFACE, EGL_NO_SURFACE, glamor_egl->context)) {
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||
"Failed to make EGL context current\n");
|
||||
return FALSE;
|
||||
}
|
||||
#ifdef GLX_USE_SHARED_DISPATCH
|
||||
GET_CURRENT_CONTEXT(glamor_egl->glamor_context);
|
||||
#endif
|
||||
glamor_egl->saved_free_screen = scrn->FreeScreen;
|
||||
scrn->FreeScreen = glamor_egl_free_screen;
|
||||
#ifdef GLAMOR_GLES2
|
||||
xf86DrvMsg(scrn->scrnIndex, X_INFO, "Using GLES2.\n");
|
||||
#ifdef GLX_USE_SHARED_DISPATCH
|
||||
xf86DrvMsg(scrn->scrnIndex, X_WARNING, "Glamor is using GLES2 but GLX needs GL. "
|
||||
xf86DrvMsg(scrn->scrnIndex, X_WARNING,
|
||||
"Glamor is using GLES2 but GLX needs GL. "
|
||||
"Indirect GLX may not work correctly.\n");
|
||||
#endif
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -846,14 +812,13 @@ glamor_egl_init_textured_pixmap(ScreenPtr screen)
|
|||
|
||||
Bool
|
||||
glamor_gl_dispatch_init(ScreenPtr screen,
|
||||
struct glamor_gl_dispatch *dispatch,
|
||||
int gl_version)
|
||||
struct glamor_gl_dispatch *dispatch, int gl_version)
|
||||
{
|
||||
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
||||
struct glamor_egl_screen_private *glamor_egl =
|
||||
glamor_egl_get_screen_private(scrn);
|
||||
if (!glamor_gl_dispatch_init_impl
|
||||
(dispatch, gl_version, (get_proc_address_t)eglGetProcAddress))
|
||||
(dispatch, gl_version, (get_proc_address_t) eglGetProcAddress))
|
||||
return FALSE;
|
||||
glamor_egl->dispatch = dispatch;
|
||||
return TRUE;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Intel Corporation
|
||||
* Copyright © 2013 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -16,44 +16,49 @@
|
|||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Chris Wilson <chris@chris-wilson.co.uk>
|
||||
*
|
||||
* Copied from sna
|
||||
*
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _GLAMOR_COMPILER_H_
|
||||
#define _GLAMOR_COMPILER_H_
|
||||
/** @file glamor_egl_stubs.c
|
||||
*
|
||||
* Stubbed out glamor_egl.c functions for servers other than Xorg.
|
||||
*/
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
|
||||
#define likely(expr) (__builtin_expect (!!(expr), 1))
|
||||
#define unlikely(expr) (__builtin_expect (!!(expr), 0))
|
||||
#define noinline __attribute__((noinline))
|
||||
#define fastcall __attribute__((regparm(3)))
|
||||
#define must_check __attribute__((warn_unused_result))
|
||||
#define constant __attribute__((const))
|
||||
#else
|
||||
#define likely(expr) (expr)
|
||||
#define unlikely(expr) (expr)
|
||||
#define noinline
|
||||
#define fastcall
|
||||
#define must_check
|
||||
#define constant
|
||||
#endif
|
||||
#include "glamor_priv.h"
|
||||
|
||||
#ifdef HAVE_VALGRIND
|
||||
#define VG(x) x
|
||||
#else
|
||||
#define VG(x)
|
||||
#endif
|
||||
void
|
||||
glamor_egl_screen_init(ScreenPtr screen)
|
||||
{
|
||||
}
|
||||
|
||||
#define VG_CLEAR(s) VG(memset(&s, 0, sizeof(s)))
|
||||
void
|
||||
glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
}
|
||||
|
||||
#define COMPILE_TIME_ASSERT(E) ((void)sizeof(char[1 - 2*!(E)]))
|
||||
void
|
||||
glamor_egl_make_current(ScreenPtr screen)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* _SNA_COMPILER_H_ */
|
||||
void
|
||||
glamor_egl_restore_context(ScreenPtr screen)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
|
||||
PixmapPtr pixmap,
|
||||
unsigned int tex,
|
||||
Bool want_name, CARD16 *stride, CARD32 *size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
glamor_egl_create_argb8888_based_texture(ScreenPtr screen, int w, int h)
|
||||
{
|
||||
return 0;
|
||||
}
|
|
@ -27,9 +27,7 @@
|
|||
* Zhigang Gong <zhigang.gong@gmail.com>
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
#include "dix-config.h"
|
||||
|
||||
#include <xorg-server.h>
|
||||
#define GLAMOR_FOR_XORG
|
||||
|
|
|
@ -44,24 +44,27 @@
|
|||
&pos->member != (head); \
|
||||
pos = __container_of(pos->member.prev, pos, member))
|
||||
|
||||
|
||||
#define xorg_list_for_each_entry_safe_reverse(pos, tmp, head, member) \
|
||||
for (pos = __container_of((head)->prev, pos, member), \
|
||||
tmp = __container_of(pos->member.prev, pos, member); \
|
||||
&pos->member != (head); \
|
||||
pos = tmp, tmp = __container_of(pos->member.prev, tmp, member))
|
||||
|
||||
inline static int cache_wbucket(int size)
|
||||
inline static int
|
||||
cache_wbucket(int size)
|
||||
{
|
||||
int order = __fls(size / 32);
|
||||
|
||||
if (order >= CACHE_BUCKET_WCOUNT)
|
||||
order = CACHE_BUCKET_WCOUNT - 1;
|
||||
return order;
|
||||
}
|
||||
|
||||
inline static int cache_hbucket(int size)
|
||||
inline static int
|
||||
cache_hbucket(int size)
|
||||
{
|
||||
int order = __fls(size / 32);
|
||||
|
||||
if (order >= CACHE_BUCKET_HCOUNT)
|
||||
order = CACHE_BUCKET_HCOUNT - 1;
|
||||
return order;
|
||||
|
@ -74,6 +77,7 @@ glamor_pixmap_fbo_cache_get(glamor_screen_private *glamor_priv,
|
|||
struct xorg_list *cache;
|
||||
glamor_pixmap_fbo *fbo_entry, *ret_fbo = NULL;
|
||||
int n_format;
|
||||
|
||||
#ifdef NO_FBO_CACHE
|
||||
return NULL;
|
||||
#else
|
||||
|
@ -126,6 +130,7 @@ void
|
|||
glamor_purge_fbo(glamor_pixmap_fbo *fbo)
|
||||
{
|
||||
glamor_gl_dispatch *dispatch = glamor_get_dispatch(fbo->glamor_priv);
|
||||
|
||||
if (fbo->fb)
|
||||
dispatch->glDeleteFramebuffers(1, &fbo->fb);
|
||||
if (fbo->tex)
|
||||
|
@ -160,8 +165,9 @@ glamor_pixmap_fbo_cache_put(glamor_pixmap_fbo *fbo)
|
|||
cache = &fbo->glamor_priv->fbo_cache[n_format]
|
||||
[cache_wbucket(fbo->width)]
|
||||
[cache_hbucket(fbo->height)];
|
||||
DEBUGF("Put cache entry %p to cache %p w %d h %d format %x fbo %d tex %d \n", fbo, cache,
|
||||
fbo->width, fbo->height, fbo->format, fbo->fb, fbo->tex);
|
||||
DEBUGF
|
||||
("Put cache entry %p to cache %p w %d h %d format %x fbo %d tex %d \n",
|
||||
fbo, cache, fbo->width, fbo->height, fbo->format, fbo->fb, fbo->tex);
|
||||
|
||||
fbo->glamor_priv->fbo_cache_watermark += fbo->width * fbo->height;
|
||||
xorg_list_add(&fbo->list, cache);
|
||||
|
@ -183,11 +189,11 @@ glamor_pixmap_ensure_fb(glamor_pixmap_fbo *fbo)
|
|||
dispatch->glBindFramebuffer(GL_FRAMEBUFFER, fbo->fb);
|
||||
dispatch->glFramebufferTexture2D(GL_FRAMEBUFFER,
|
||||
GL_COLOR_ATTACHMENT0,
|
||||
GL_TEXTURE_2D, fbo->tex,
|
||||
0);
|
||||
GL_TEXTURE_2D, fbo->tex, 0);
|
||||
status = dispatch->glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE) {
|
||||
const char *str;
|
||||
|
||||
switch (status) {
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
|
||||
str = "incomplete attachment";
|
||||
|
@ -238,6 +244,7 @@ glamor_create_fbo_from_tex(glamor_screen_private *glamor_priv,
|
|||
|
||||
if (flag == GLAMOR_CREATE_PIXMAP_MAP) {
|
||||
glamor_gl_dispatch *dispatch;
|
||||
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glGenBuffers(1, &fbo->pbo);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
|
@ -247,31 +254,32 @@ glamor_create_fbo_from_tex(glamor_screen_private *glamor_priv,
|
|||
if (flag != GLAMOR_CREATE_FBO_NO_FBO)
|
||||
glamor_pixmap_ensure_fb(fbo);
|
||||
|
||||
done:
|
||||
done:
|
||||
return fbo;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
glamor_fbo_expire(glamor_screen_private *glamor_priv)
|
||||
{
|
||||
struct xorg_list *cache;
|
||||
glamor_pixmap_fbo *fbo_entry, *tmp;
|
||||
int i,j,k;
|
||||
int i, j, k;
|
||||
|
||||
for(i = 0; i < CACHE_FORMAT_COUNT; i++)
|
||||
for(j = 0; j < CACHE_BUCKET_WCOUNT; j++)
|
||||
for(k = 0; k < CACHE_BUCKET_HCOUNT; k++) {
|
||||
for (i = 0; i < CACHE_FORMAT_COUNT; i++)
|
||||
for (j = 0; j < CACHE_BUCKET_WCOUNT; j++)
|
||||
for (k = 0; k < CACHE_BUCKET_HCOUNT; k++) {
|
||||
cache = &glamor_priv->fbo_cache[i][j][k];
|
||||
xorg_list_for_each_entry_safe_reverse(fbo_entry, tmp, cache, list) {
|
||||
xorg_list_for_each_entry_safe_reverse(fbo_entry, tmp, cache,
|
||||
list) {
|
||||
if (GLAMOR_TICK_AFTER(fbo_entry->expire, glamor_priv->tick)) {
|
||||
break;
|
||||
}
|
||||
|
||||
glamor_priv->fbo_cache_watermark -= fbo_entry->width * fbo_entry->height;
|
||||
glamor_priv->fbo_cache_watermark -=
|
||||
fbo_entry->width * fbo_entry->height;
|
||||
xorg_list_del(&fbo_entry->list);
|
||||
DEBUGF("cache %p fbo %p expired %d current %d \n", cache, fbo_entry,
|
||||
fbo_entry->expire, glamor_priv->tick);
|
||||
DEBUGF("cache %p fbo %p expired %d current %d \n", cache,
|
||||
fbo_entry, fbo_entry->expire, glamor_priv->tick);
|
||||
glamor_purge_fbo(fbo_entry);
|
||||
}
|
||||
}
|
||||
|
@ -282,13 +290,12 @@ void
|
|||
glamor_init_pixmap_fbo(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv;
|
||||
int i,j,k;
|
||||
int i, j, k;
|
||||
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
for(i = 0; i < CACHE_FORMAT_COUNT; i++)
|
||||
for(j = 0; j < CACHE_BUCKET_WCOUNT; j++)
|
||||
for(k = 0; k < CACHE_BUCKET_HCOUNT; k++)
|
||||
{
|
||||
for (i = 0; i < CACHE_FORMAT_COUNT; i++)
|
||||
for (j = 0; j < CACHE_BUCKET_WCOUNT; j++)
|
||||
for (k = 0; k < CACHE_BUCKET_HCOUNT; k++) {
|
||||
xorg_list_init(&glamor_priv->fbo_cache[i][j][k]);
|
||||
}
|
||||
glamor_priv->fbo_cache_watermark = 0;
|
||||
|
@ -300,15 +307,15 @@ glamor_fini_pixmap_fbo(ScreenPtr screen)
|
|||
struct xorg_list *cache;
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_pixmap_fbo *fbo_entry, *tmp;
|
||||
int i,j,k;
|
||||
int i, j, k;
|
||||
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
for(i = 0; i < CACHE_FORMAT_COUNT; i++)
|
||||
for(j = 0; j < CACHE_BUCKET_WCOUNT; j++)
|
||||
for(k = 0; k < CACHE_BUCKET_HCOUNT; k++)
|
||||
{
|
||||
for (i = 0; i < CACHE_FORMAT_COUNT; i++)
|
||||
for (j = 0; j < CACHE_BUCKET_WCOUNT; j++)
|
||||
for (k = 0; k < CACHE_BUCKET_HCOUNT; k++) {
|
||||
cache = &glamor_priv->fbo_cache[i][j][k];
|
||||
xorg_list_for_each_entry_safe_reverse(fbo_entry, tmp, cache, list) {
|
||||
xorg_list_for_each_entry_safe_reverse(fbo_entry, tmp, cache,
|
||||
list) {
|
||||
xorg_list_del(&fbo_entry->list);
|
||||
glamor_purge_fbo(fbo_entry);
|
||||
}
|
||||
|
@ -334,13 +341,11 @@ _glamor_create_tex(glamor_screen_private *glamor_priv,
|
|||
* Depending on the implementation, GL_RGBA might not
|
||||
* give us ARGB8888. We ask glamor_egl to use get
|
||||
* an ARGB8888 based texture for us. */
|
||||
if (glamor_priv->dri3_enabled && format == GL_RGBA)
|
||||
{
|
||||
if (glamor_priv->dri3_enabled && format == GL_RGBA) {
|
||||
tex = glamor_egl_create_argb8888_based_texture(glamor_priv->screen,
|
||||
w, h);
|
||||
}
|
||||
if (!tex)
|
||||
{
|
||||
if (!tex) {
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glGenTextures(1, &tex);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, tex);
|
||||
|
@ -357,9 +362,7 @@ _glamor_create_tex(glamor_screen_private *glamor_priv,
|
|||
|
||||
glamor_pixmap_fbo *
|
||||
glamor_create_fbo(glamor_screen_private *glamor_priv,
|
||||
int w, int h,
|
||||
GLenum format,
|
||||
int flag)
|
||||
int w, int h, GLenum format, int flag)
|
||||
{
|
||||
glamor_pixmap_fbo *fbo;
|
||||
GLint tex = 0;
|
||||
|
@ -379,13 +382,12 @@ glamor_create_fbo(glamor_screen_private *glamor_priv,
|
|||
else
|
||||
cache_flag = 0;
|
||||
|
||||
fbo = glamor_pixmap_fbo_cache_get(glamor_priv, w, h,
|
||||
format, cache_flag);
|
||||
fbo = glamor_pixmap_fbo_cache_get(glamor_priv, w, h, format, cache_flag);
|
||||
if (fbo)
|
||||
return fbo;
|
||||
new_fbo:
|
||||
new_fbo:
|
||||
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);
|
||||
|
||||
return fbo;
|
||||
|
@ -395,14 +397,13 @@ static glamor_pixmap_fbo *
|
|||
_glamor_create_fbo_array(glamor_screen_private *glamor_priv,
|
||||
int w, int h, GLenum format, int flag,
|
||||
int block_w, int block_h,
|
||||
glamor_pixmap_private *pixmap_priv,
|
||||
int has_fbo)
|
||||
glamor_pixmap_private *pixmap_priv, int has_fbo)
|
||||
{
|
||||
int block_wcnt;
|
||||
int block_hcnt;
|
||||
glamor_pixmap_fbo **fbo_array;
|
||||
BoxPtr box_array;
|
||||
int i,j;
|
||||
int i, j;
|
||||
glamor_pixmap_private_large_t *priv;
|
||||
|
||||
priv = &pixmap_priv->large;
|
||||
|
@ -414,13 +415,12 @@ _glamor_create_fbo_array(glamor_screen_private *glamor_priv,
|
|||
if (box_array == 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) {
|
||||
free(box_array);
|
||||
return FALSE;
|
||||
}
|
||||
for(i = 0; i < block_hcnt; i++)
|
||||
{
|
||||
for (i = 0; i < block_hcnt; i++) {
|
||||
int block_y1, block_y2;
|
||||
int fbo_w, fbo_h;
|
||||
|
||||
|
@ -428,16 +428,19 @@ _glamor_create_fbo_array(glamor_screen_private *glamor_priv,
|
|||
block_y2 = (block_y1 + block_h) > h ? h : (block_y1 + block_h);
|
||||
fbo_h = block_y2 - block_y1;
|
||||
|
||||
for (j = 0; j < block_wcnt; j++)
|
||||
{
|
||||
for (j = 0; j < block_wcnt; j++) {
|
||||
box_array[i * block_wcnt + j].x1 = j * block_w;
|
||||
box_array[i * block_wcnt + j].y1 = block_y1;
|
||||
box_array[i * block_wcnt + j].x2 = (j + 1) * block_w > w ? w : (j + 1) * block_w;
|
||||
box_array[i * block_wcnt + j].x2 =
|
||||
(j + 1) * block_w > w ? w : (j + 1) * block_w;
|
||||
box_array[i * block_wcnt + j].y2 = block_y2;
|
||||
fbo_w = box_array[i * block_wcnt + j].x2 - box_array[i * block_wcnt + j].x1;
|
||||
fbo_w =
|
||||
box_array[i * block_wcnt + j].x2 - box_array[i * block_wcnt +
|
||||
j].x1;
|
||||
if (!has_fbo)
|
||||
fbo_array[i * block_wcnt + j] = glamor_create_fbo(glamor_priv,
|
||||
fbo_w, fbo_h, format,
|
||||
fbo_w, fbo_h,
|
||||
format,
|
||||
GLAMOR_CREATE_PIXMAP_FIXUP);
|
||||
else
|
||||
fbo_array[i * block_wcnt + j] = priv->base.fbo;
|
||||
|
@ -453,8 +456,8 @@ _glamor_create_fbo_array(glamor_screen_private *glamor_priv,
|
|||
priv->block_hcnt = block_hcnt;
|
||||
return fbo_array[0];
|
||||
|
||||
cleanup:
|
||||
for(i = 0; i < block_wcnt * block_hcnt; i++)
|
||||
cleanup:
|
||||
for (i = 0; i < block_wcnt * block_hcnt; i++)
|
||||
if ((fbo_array)[i])
|
||||
glamor_destroy_fbo((fbo_array)[i]);
|
||||
free(box_array);
|
||||
|
@ -462,7 +465,6 @@ cleanup:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Create a fbo array to cover the w*h region, by using block_w*block_h
|
||||
* block.*/
|
||||
glamor_pixmap_fbo *
|
||||
|
@ -514,7 +516,7 @@ glamor_pixmap_attach_fbo(PixmapPtr pixmap, glamor_pixmap_fbo *fbo)
|
|||
if (fbo->tex != 0)
|
||||
pixmap_priv->base.gl_tex = 1;
|
||||
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;
|
||||
}
|
||||
case GLAMOR_MEMORY_MAP:
|
||||
|
@ -529,13 +531,16 @@ void
|
|||
glamor_pixmap_destroy_fbo(glamor_pixmap_private *priv)
|
||||
{
|
||||
glamor_pixmap_fbo *fbo;
|
||||
|
||||
if (priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
int i;
|
||||
glamor_pixmap_private_large_t *large = &priv->large;
|
||||
for(i = 0; i < large->block_wcnt * large->block_hcnt; i++)
|
||||
|
||||
for (i = 0; i < large->block_wcnt * large->block_hcnt; i++)
|
||||
glamor_destroy_fbo(large->fbo_array[i]);
|
||||
free(large->fbo_array);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fbo = glamor_pixmap_detach_fbo(priv);
|
||||
if (fbo)
|
||||
glamor_destroy_fbo(fbo);
|
||||
|
@ -556,17 +561,17 @@ glamor_pixmap_ensure_fbo(PixmapPtr pixmap, GLenum format, int flag)
|
|||
if (pixmap_priv->base.fbo == NULL) {
|
||||
|
||||
fbo = glamor_create_fbo(glamor_priv, pixmap->drawable.width,
|
||||
pixmap->drawable.height,
|
||||
format,
|
||||
flag);
|
||||
pixmap->drawable.height, format, flag);
|
||||
if (fbo == NULL)
|
||||
return FALSE;
|
||||
|
||||
glamor_pixmap_attach_fbo(pixmap, fbo);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* We do have a fbo, but it may lack of fb or tex. */
|
||||
if (!pixmap_priv->base.fbo->tex)
|
||||
pixmap_priv->base.fbo->tex = _glamor_create_tex(glamor_priv, pixmap->drawable.width,
|
||||
pixmap_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)
|
||||
|
|
|
@ -49,8 +49,7 @@ glamor_fill(DrawablePtr drawable,
|
|||
if (!glamor_solid(dst_pixmap,
|
||||
x + off_x,
|
||||
y + off_y,
|
||||
width, height, gc->alu, gc->planemask,
|
||||
gc->fgPixel))
|
||||
width, height, gc->alu, gc->planemask, gc->fgPixel))
|
||||
goto fail;
|
||||
break;
|
||||
case FillStippled:
|
||||
|
@ -64,8 +63,7 @@ glamor_fill(DrawablePtr drawable,
|
|||
gc->alu,
|
||||
gc->planemask,
|
||||
gc->fgPixel,
|
||||
gc->bgPixel, gc->patOrg.x,
|
||||
gc->patOrg.y))
|
||||
gc->bgPixel, gc->patOrg.x, gc->patOrg.y))
|
||||
goto fail;
|
||||
break;
|
||||
case FillTiled:
|
||||
|
@ -142,19 +140,24 @@ glamor_init_solid_shader(ScreenPtr screen)
|
|||
glamor_gl_dispatch *dispatch;
|
||||
const char *solid_vs =
|
||||
"attribute vec4 v_position;"
|
||||
"void main()\n" "{\n" " gl_Position = v_position;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = v_position;\n"
|
||||
"}\n";
|
||||
const char *solid_fs =
|
||||
GLAMOR_DEFAULT_PRECISION "uniform vec4 color;\n"
|
||||
"void main()\n" "{\n" " gl_FragColor = color;\n" "}\n";
|
||||
GLAMOR_DEFAULT_PRECISION
|
||||
"uniform vec4 color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_FragColor = color;\n"
|
||||
"}\n";
|
||||
GLint fs_prog, vs_prog;
|
||||
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
glamor_priv->solid_prog = dispatch->glCreateProgram();
|
||||
vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, solid_vs);
|
||||
fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
|
||||
solid_fs);
|
||||
fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER, solid_fs);
|
||||
dispatch->glAttachShader(glamor_priv->solid_prog, vs_prog);
|
||||
dispatch->glAttachShader(glamor_priv->solid_prog, fs_prog);
|
||||
|
||||
|
@ -163,8 +166,7 @@ glamor_init_solid_shader(ScreenPtr screen)
|
|||
glamor_link_glsl_prog(dispatch, glamor_priv->solid_prog);
|
||||
|
||||
glamor_priv->solid_color_uniform_location =
|
||||
dispatch->glGetUniformLocation(glamor_priv->solid_prog,
|
||||
"color");
|
||||
dispatch->glGetUniformLocation(glamor_priv->solid_prog, "color");
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
}
|
||||
|
||||
|
@ -184,10 +186,8 @@ static void
|
|||
_glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
|
||||
{
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_gl_dispatch *dispatch;
|
||||
GLfloat xscale, yscale;
|
||||
float vertices[32];
|
||||
|
@ -199,38 +199,38 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
|
|||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glUseProgram(glamor_priv->solid_prog);
|
||||
|
||||
dispatch->glUniform4fv(glamor_priv->solid_color_uniform_location,
|
||||
1, color);
|
||||
dispatch->glUniform4fv(glamor_priv->solid_color_uniform_location, 1, color);
|
||||
|
||||
pixmap_priv_get_dest_scale(pixmap_priv, &xscale, &yscale);
|
||||
|
||||
if (unlikely(nbox*4*2 > ARRAY_SIZE(vertices))) {
|
||||
if (_X_UNLIKELY(nbox * 4 * 2 > ARRAY_SIZE(vertices))) {
|
||||
int allocated_box;
|
||||
|
||||
if (nbox * 6 > GLAMOR_COMPOSITE_VBO_VERT_CNT) {
|
||||
allocated_box = GLAMOR_COMPOSITE_VBO_VERT_CNT / 6;
|
||||
} else
|
||||
}
|
||||
else
|
||||
allocated_box = nbox;
|
||||
pvertices = malloc(allocated_box * 4 * 2 * sizeof(float));
|
||||
if (pvertices)
|
||||
valid_nbox = allocated_box;
|
||||
else {
|
||||
pvertices = vertices;
|
||||
valid_nbox = ARRAY_SIZE(vertices) / (4*2);
|
||||
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->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
pvertices);
|
||||
GL_FALSE, 2 * sizeof(float), pvertices);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
|
||||
while(nbox) {
|
||||
while (nbox) {
|
||||
int box_cnt, i;
|
||||
float *valid_vertices;
|
||||
|
||||
valid_vertices = pvertices;
|
||||
box_cnt = nbox > valid_nbox ? valid_nbox : nbox;
|
||||
for (i = 0; i < box_cnt; i++) {
|
||||
|
@ -239,7 +239,7 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
|
|||
box[i].x2, box[i].y2,
|
||||
glamor_priv->yInverted,
|
||||
valid_vertices);
|
||||
valid_vertices += 4*2;
|
||||
valid_vertices += 4 * 2;
|
||||
}
|
||||
if (box_cnt == 1)
|
||||
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, box_cnt * 4);
|
||||
|
@ -248,14 +248,10 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
|
|||
dispatch->glDrawRangeElements(GL_TRIANGLES,
|
||||
0,
|
||||
box_cnt * 4,
|
||||
box_cnt * 6,
|
||||
GL_UNSIGNED_SHORT,
|
||||
NULL);
|
||||
box_cnt * 6, GL_UNSIGNED_SHORT, NULL);
|
||||
#else
|
||||
dispatch->glDrawElements(GL_TRIANGLES,
|
||||
box_cnt * 6,
|
||||
GL_UNSIGNED_SHORT,
|
||||
NULL);
|
||||
box_cnt * 6, GL_UNSIGNED_SHORT, NULL);
|
||||
#endif
|
||||
nbox -= box_cnt;
|
||||
box += box_cnt;
|
||||
|
@ -273,8 +269,7 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
|
|||
|
||||
Bool
|
||||
glamor_solid_boxes(PixmapPtr pixmap,
|
||||
BoxPtr box, int nbox,
|
||||
unsigned long fg_pixel)
|
||||
BoxPtr box, int nbox, unsigned long fg_pixel)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
GLfloat color[4];
|
||||
|
@ -287,8 +282,7 @@ glamor_solid_boxes(PixmapPtr pixmap,
|
|||
glamor_get_rgba_from_pixel(fg_pixel,
|
||||
&color[0],
|
||||
&color[1],
|
||||
&color[2],
|
||||
&color[3], format_for_pixmap(pixmap));
|
||||
&color[2], &color[3], format_for_pixmap(pixmap));
|
||||
|
||||
if (pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
RegionRec region;
|
||||
|
@ -297,11 +291,13 @@ glamor_solid_boxes(PixmapPtr pixmap,
|
|||
int i;
|
||||
|
||||
RegionInitBoxes(®ion, box, nbox);
|
||||
clipped_regions = glamor_compute_clipped_regions(pixmap_priv, ®ion, &n_region, 0, 0, 0);
|
||||
for(i = 0; i < n_region; i++)
|
||||
{
|
||||
clipped_regions =
|
||||
glamor_compute_clipped_regions(pixmap_priv, ®ion, &n_region, 0,
|
||||
0, 0);
|
||||
for (i = 0; i < n_region; i++) {
|
||||
BoxPtr inner_box;
|
||||
int inner_nbox;
|
||||
|
||||
SET_PIXMAP_FBO_CURRENT(pixmap_priv, clipped_regions[i].block_idx);
|
||||
|
||||
inner_box = RegionRects(clipped_regions[i].region);
|
||||
|
@ -311,7 +307,8 @@ glamor_solid_boxes(PixmapPtr pixmap,
|
|||
}
|
||||
free(clipped_regions);
|
||||
RegionUninit(®ion);
|
||||
} else
|
||||
}
|
||||
else
|
||||
_glamor_solid_boxes(pixmap, box, nbox, color);
|
||||
|
||||
return TRUE;
|
||||
|
@ -319,12 +316,10 @@ glamor_solid_boxes(PixmapPtr pixmap,
|
|||
|
||||
Bool
|
||||
glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
|
||||
unsigned char alu, unsigned long planemask,
|
||||
unsigned long fg_pixel)
|
||||
unsigned char alu, unsigned long planemask, unsigned long fg_pixel)
|
||||
{
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
BoxRec box;
|
||||
|
@ -335,8 +330,7 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
|
|||
return FALSE;
|
||||
|
||||
if (!glamor_set_planemask(pixmap, planemask)) {
|
||||
glamor_fallback
|
||||
("Failedto set planemask in glamor_solid.\n");
|
||||
glamor_fallback("Failedto set planemask in glamor_solid.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -361,4 +355,3 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
static Bool
|
||||
_glamor_fill_spans(DrawablePtr drawable,
|
||||
GCPtr gc,
|
||||
int n, DDXPointPtr points, int *widths, int sorted, Bool fallback)
|
||||
int n, DDXPointPtr points, int *widths, int sorted,
|
||||
Bool fallback)
|
||||
{
|
||||
DDXPointPtr ppt;
|
||||
int nbox;
|
||||
|
@ -71,9 +72,8 @@ _glamor_fill_spans(DrawablePtr drawable,
|
|||
ret = TRUE;
|
||||
goto done;
|
||||
|
||||
fail:
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(drawable)
|
||||
fail:
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(drawable)
|
||||
&& glamor_ddx_fallback_check_gc(gc)) {
|
||||
goto done;
|
||||
}
|
||||
|
@ -81,23 +81,20 @@ fail:
|
|||
glamor_get_drawable_location(drawable));
|
||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||
if (glamor_prepare_access_gc(gc)) {
|
||||
fbFillSpans(drawable, gc, n, points, widths,
|
||||
sorted);
|
||||
fbFillSpans(drawable, gc, n, points, widths, sorted);
|
||||
glamor_finish_access_gc(gc);
|
||||
}
|
||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
ret = TRUE;
|
||||
|
||||
done:
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
glamor_fill_spans(DrawablePtr drawable,
|
||||
GCPtr gc,
|
||||
int n, DDXPointPtr points, int *widths, int sorted)
|
||||
GCPtr gc, int n, DDXPointPtr points, int *widths, int sorted)
|
||||
{
|
||||
_glamor_fill_spans(drawable, gc, n, points, widths, sorted, TRUE);
|
||||
}
|
||||
|
@ -109,5 +106,3 @@ glamor_fill_spans_nf(DrawablePtr drawable,
|
|||
{
|
||||
return _glamor_fill_spans(drawable, gc, n, points, widths, sorted, FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include "glamor_priv.h"
|
||||
|
||||
|
||||
static Bool
|
||||
_glamor_get_image(DrawablePtr drawable, int x, int y, int w, int h,
|
||||
unsigned int format, unsigned long planeMask, char *d,
|
||||
|
@ -49,13 +48,11 @@ _glamor_get_image(DrawablePtr drawable, int x, int y, int w, int h,
|
|||
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
|
||||
|
||||
if (!glamor_set_planemask(pixmap, planeMask)) {
|
||||
glamor_fallback
|
||||
("Failedto set planemask in glamor_solid.\n");
|
||||
glamor_fallback("Failedto set planemask in glamor_solid.\n");
|
||||
goto fall_back;
|
||||
}
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||
goto fall_back;
|
||||
stride = PixmapBytePad(w, drawable->depth);
|
||||
|
@ -69,7 +66,7 @@ _glamor_get_image(DrawablePtr drawable, int x, int y, int w, int h,
|
|||
assert(data == d);
|
||||
return TRUE;
|
||||
}
|
||||
fall_back:
|
||||
fall_back:
|
||||
sub_pixmap = glamor_get_sub_pixmap(pixmap, x + x_off + drawable->x,
|
||||
y + y_off + drawable->y, w, h,
|
||||
GLAMOR_ACCESS_RO);
|
||||
|
@ -77,9 +74,9 @@ fall_back:
|
|||
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
|
||||
y + y_off + drawable->y, w, h, GLAMOR_ACCESS_RO);
|
||||
}
|
||||
else
|
||||
miGetImage(drawable, x, y, w, h, format, planeMask, d);
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -35,8 +35,7 @@ _glamor_get_spans(DrawablePtr drawable,
|
|||
Bool fallback)
|
||||
{
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
int i;
|
||||
uint8_t *readpixels_dst = (uint8_t *) dst;
|
||||
void *data;
|
||||
|
@ -49,19 +48,22 @@ _glamor_get_spans(DrawablePtr drawable,
|
|||
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
|
||||
for (i = 0; i < count; i++) {
|
||||
data = glamor_download_sub_pixmap_to_cpu(pixmap, points[i].x + x_off,
|
||||
points[i].y + y_off, widths[i], 1,
|
||||
PixmapBytePad(widths[i], drawable->depth),
|
||||
readpixels_dst, 0, GLAMOR_ACCESS_RO);
|
||||
points[i].y + y_off, widths[i],
|
||||
1, PixmapBytePad(widths[i],
|
||||
drawable->
|
||||
depth),
|
||||
readpixels_dst, 0,
|
||||
GLAMOR_ACCESS_RO);
|
||||
(void)data;
|
||||
assert(data == readpixels_dst);
|
||||
readpixels_dst += PixmapBytePad(widths[i], drawable->depth);
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
goto done;
|
||||
fail:
|
||||
fail:
|
||||
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(drawable))
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(drawable))
|
||||
goto done;
|
||||
|
||||
ret = TRUE;
|
||||
|
@ -69,7 +71,7 @@ fail:
|
|||
fbGetSpans(drawable, wmax, points, widths, count, dst);
|
||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RO);
|
||||
}
|
||||
done:
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -78,8 +80,7 @@ glamor_get_spans(DrawablePtr drawable,
|
|||
int wmax,
|
||||
DDXPointPtr points, int *widths, int count, char *dst)
|
||||
{
|
||||
_glamor_get_spans(drawable, wmax, points,
|
||||
widths, count, dst, TRUE);
|
||||
_glamor_get_spans(drawable, wmax, points, widths, count, dst, TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
|
@ -87,9 +88,5 @@ glamor_get_spans_nf(DrawablePtr drawable,
|
|||
int wmax,
|
||||
DDXPointPtr points, int *widths, int count, char *dst)
|
||||
{
|
||||
return _glamor_get_spans(drawable, wmax, points,
|
||||
widths, count, dst, FALSE);
|
||||
return _glamor_get_spans(drawable, wmax, points, widths, count, dst, FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,17 +2,19 @@ typedef struct glamor_gl_dispatch {
|
|||
/* Transformation functions */
|
||||
void (*glMatrixMode) (GLenum mode);
|
||||
void (*glLoadIdentity) (void);
|
||||
void (*glViewport) (GLint x, GLint y, GLsizei width,
|
||||
GLsizei height);
|
||||
void (*glViewport) (GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
/* Drawing functions */
|
||||
void (*glRasterPos2i) (GLint x, GLint y);
|
||||
|
||||
/* Vertex Array */
|
||||
void (*glDrawArrays) (GLenum mode, GLint first, GLsizei count);
|
||||
|
||||
/* Elements Array*/
|
||||
void (*glDrawElements) (GLenum mode, GLsizei count, GLenum type, const GLvoid * indices);
|
||||
void (*glDrawRangeElements) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid * indices);
|
||||
/* Elements Array */
|
||||
void (*glDrawElements) (GLenum mode, GLsizei count, GLenum type,
|
||||
const GLvoid * indices);
|
||||
void (*glDrawRangeElements) (GLenum mode, GLuint start, GLuint end,
|
||||
GLsizei count, GLenum type,
|
||||
const GLvoid * indices);
|
||||
|
||||
/* Raster functions */
|
||||
void (*glReadPixels) (GLint x, GLint y,
|
||||
|
@ -20,8 +22,7 @@ typedef struct glamor_gl_dispatch {
|
|||
GLenum format, GLenum type, GLvoid * pixels);
|
||||
|
||||
void (*glDrawPixels) (GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type,
|
||||
const GLvoid * pixels);
|
||||
GLenum format, GLenum type, const GLvoid * pixels);
|
||||
void (*glPixelStorei) (GLenum pname, GLint param);
|
||||
/* Texture Mapping */
|
||||
|
||||
|
@ -38,15 +39,13 @@ typedef struct glamor_gl_dispatch {
|
|||
void (*glTexSubImage2D) (GLenum target, GLint level,
|
||||
GLint xoffset, GLint yoffset,
|
||||
GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type,
|
||||
const GLvoid * pixels);
|
||||
GLenum format, GLenum type, const GLvoid * pixels);
|
||||
/* MISC */
|
||||
void (*glFlush) (void);
|
||||
void (*glFinish) (void);
|
||||
void (*glGetIntegerv) (GLenum pname, GLint * params);
|
||||
const GLubyte *(*glGetString) (GLenum name);
|
||||
void (*glScissor) (GLint x, GLint y, GLsizei width,
|
||||
GLsizei height);
|
||||
void (*glScissor) (GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
void (*glEnable) (GLenum cap);
|
||||
void (*glDisable) (GLenum cap);
|
||||
void (*glBlendFunc) (GLenum sfactor, GLenum dfactor);
|
||||
|
@ -60,8 +59,9 @@ typedef struct glamor_gl_dispatch {
|
|||
void (*glBufferData) (GLenum target, GLsizeiptr size,
|
||||
const GLvoid * data, GLenum usage);
|
||||
GLvoid *(*glMapBuffer) (GLenum target, GLenum access);
|
||||
GLvoid *(*glMapBufferRange) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
|
||||
GLboolean (*glUnmapBuffer) (GLenum target);
|
||||
GLvoid *(*glMapBufferRange) (GLenum target, GLintptr offset,
|
||||
GLsizeiptr length, GLbitfield access);
|
||||
GLboolean(*glUnmapBuffer) (GLenum target);
|
||||
void (*glBindBuffer) (GLenum target, GLuint buffer);
|
||||
void (*glDeleteBuffers) (GLsizei n, const GLuint * buffers);
|
||||
|
||||
|
@ -69,10 +69,9 @@ typedef struct glamor_gl_dispatch {
|
|||
GLenum textarget, GLuint texture,
|
||||
GLint level);
|
||||
void (*glBindFramebuffer) (GLenum target, GLuint framebuffer);
|
||||
void (*glDeleteFramebuffers) (GLsizei n,
|
||||
const GLuint * framebuffers);
|
||||
void (*glDeleteFramebuffers) (GLsizei n, const GLuint * framebuffers);
|
||||
void (*glGenFramebuffers) (GLsizei n, GLuint * framebuffers);
|
||||
GLenum (*glCheckFramebufferStatus) (GLenum target);
|
||||
GLenum(*glCheckFramebufferStatus) (GLenum target);
|
||||
void (*glBlitFramebuffer) (GLint srcX0, GLint srcY0, GLint srcX1,
|
||||
GLint srcY1, GLint dstX0, GLint dstY0,
|
||||
GLint dstX1, GLint dstY1,
|
||||
|
@ -80,8 +79,7 @@ typedef struct glamor_gl_dispatch {
|
|||
|
||||
void (*glVertexAttribPointer) (GLuint index, GLint size,
|
||||
GLenum type, GLboolean normalized,
|
||||
GLsizei stride,
|
||||
const GLvoid * pointer);
|
||||
GLsizei stride, const GLvoid * pointer);
|
||||
void (*glDisableVertexAttribArray) (GLuint index);
|
||||
void (*glEnableVertexAttribArray) (GLuint index);
|
||||
void (*glBindAttribLocation) (GLuint program, GLuint index,
|
||||
|
@ -89,50 +87,42 @@ typedef struct glamor_gl_dispatch {
|
|||
|
||||
void (*glLinkProgram) (GLuint program);
|
||||
void (*glShaderSource) (GLuint shader, GLsizei count,
|
||||
const GLchar * *string,
|
||||
const GLint * length);
|
||||
const GLchar * *string, const GLint * length);
|
||||
void (*glUseProgram) (GLuint program);
|
||||
void (*glUniform1i) (GLint location, GLint v0);
|
||||
void (*glUniform1f) (GLint location, GLfloat v0);
|
||||
void (*glUniform4f) (GLint location, GLfloat v0, GLfloat v1,
|
||||
GLfloat v2, GLfloat v3);
|
||||
void (*glUniform1fv) (GLint location, GLsizei count,
|
||||
const GLfloat * value);
|
||||
void (*glUniform2fv) (GLint location, GLsizei count,
|
||||
const GLfloat * value);
|
||||
void (*glUniform4fv) (GLint location, GLsizei count,
|
||||
const GLfloat * value);
|
||||
void (*glUniform1fv) (GLint location, GLsizei count, const GLfloat * value);
|
||||
void (*glUniform2fv) (GLint location, GLsizei count, const GLfloat * value);
|
||||
void (*glUniform4fv) (GLint location, GLsizei count, const GLfloat * value);
|
||||
void (*glUniformMatrix3fv) (GLint location, GLsizei count,
|
||||
GLboolean transpose, const GLfloat* value);
|
||||
GLuint (*glCreateProgram) (void);
|
||||
GLuint (*glDeleteProgram) (GLuint);
|
||||
GLuint (*glCreateShader) (GLenum type);
|
||||
GLboolean transpose, const GLfloat * value);
|
||||
GLuint(*glCreateProgram) (void);
|
||||
GLuint(*glDeleteProgram) (GLuint);
|
||||
GLuint(*glCreateShader) (GLenum type);
|
||||
void (*glCompileShader) (GLuint shader);
|
||||
void (*glAttachShader) (GLuint program, GLuint shader);
|
||||
void (*glDeleteShader) (GLuint shader);
|
||||
void (*glGetShaderiv) (GLuint shader, GLenum pname,
|
||||
GLint * params);
|
||||
void (*glGetShaderiv) (GLuint shader, GLenum pname, GLint * params);
|
||||
void (*glGetShaderInfoLog) (GLuint shader, GLsizei bufSize,
|
||||
GLsizei * length, GLchar * infoLog);
|
||||
void (*glGetProgramiv) (GLuint program, GLenum pname,
|
||||
GLint * params);
|
||||
void (*glGetProgramiv) (GLuint program, GLenum pname, GLint * params);
|
||||
void (*glGetProgramInfoLog) (GLuint program, GLsizei bufSize,
|
||||
GLsizei * length, GLchar * infoLog);
|
||||
GLint (*glGetUniformLocation) (GLuint program,
|
||||
const GLchar * name);
|
||||
GLint(*glGetUniformLocation) (GLuint program, const GLchar * name);
|
||||
|
||||
} glamor_gl_dispatch;
|
||||
|
||||
|
||||
typedef void *(*get_proc_address_t) (const char *);
|
||||
|
||||
_X_EXPORT Bool
|
||||
|
||||
glamor_gl_dispatch_init_impl(struct glamor_gl_dispatch *dispatch,
|
||||
int gl_version,
|
||||
get_proc_address_t get_proc_address);
|
||||
|
||||
|
||||
_X_EXPORT Bool
|
||||
|
||||
glamor_gl_dispatch_init(ScreenPtr screen,
|
||||
struct glamor_gl_dispatch *dispatch,
|
||||
int gl_version);
|
||||
struct glamor_gl_dispatch *dispatch, int gl_version);
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifdef GLAMOR_GLES2
|
||||
|
||||
#define GL_BGRA GL_BGRA_EXT
|
||||
|
|
|
@ -31,10 +31,9 @@
|
|||
static Bool
|
||||
_glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr * ppci, pointer pglyphBase, Bool fallback)
|
||||
CharInfoPtr *ppci, void *pglyphBase, Bool fallback)
|
||||
{
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(pDrawable)
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(pDrawable)
|
||||
&& glamor_ddx_fallback_check_gc(pGC))
|
||||
return FALSE;
|
||||
|
||||
|
@ -45,26 +44,27 @@ _glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
|||
void
|
||||
glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
||||
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
|
||||
glamor_image_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||
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
|
||||
_glamor_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr * ppci, pointer pglyphBase, Bool fallback)
|
||||
CharInfoPtr *ppci, void *pglyphBase, Bool fallback)
|
||||
{
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(pDrawable)
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(pDrawable)
|
||||
&& glamor_ddx_fallback_check_gc(pGC))
|
||||
return FALSE;
|
||||
|
||||
|
@ -75,25 +75,27 @@ _glamor_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
|||
void
|
||||
glamor_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
||||
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
|
||||
glamor_poly_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||
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
|
||||
_glamor_push_pixels(GCPtr pGC, PixmapPtr pBitmap,
|
||||
DrawablePtr pDrawable, int w, int h, int x, int y, Bool fallback)
|
||||
DrawablePtr pDrawable, int w, int h, int x, int y,
|
||||
Bool fallback)
|
||||
{
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(pDrawable)
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(pDrawable)
|
||||
&& glamor_ddx_fallback_check_pixmap(&pBitmap->drawable)
|
||||
&& glamor_ddx_fallback_check_gc(pGC))
|
||||
return FALSE;
|
||||
|
@ -115,4 +117,3 @@ glamor_push_pixels_nf(GCPtr pGC, PixmapPtr pBitmap,
|
|||
{
|
||||
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
|
@ -38,13 +38,13 @@ enum glamor_pixmap_status
|
|||
glamor_upload_picture_to_texture(PicturePtr picture)
|
||||
{
|
||||
PixmapPtr pixmap;
|
||||
|
||||
assert(picture->pDrawable);
|
||||
pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
|
||||
|
||||
return glamor_upload_pixmap_to_texture(pixmap);
|
||||
}
|
||||
|
||||
|
||||
Bool
|
||||
glamor_prepare_access_picture(PicturePtr picture, glamor_access_t access)
|
||||
{
|
||||
|
@ -86,7 +86,8 @@ glamor_create_picture(PicturePtr picture)
|
|||
* the uploading, we need to know the picture format. */
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_MEMORY);
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
|
||||
/* If the picture format is not compatible with glamor fbo format,
|
||||
* we have to mark this pixmap as a separated texture, and don't
|
||||
|
@ -125,7 +126,7 @@ glamor_destroy_picture(PicturePtr picture)
|
|||
|
||||
void
|
||||
glamor_picture_format_fixup(PicturePtr picture,
|
||||
glamor_pixmap_private * pixmap_priv)
|
||||
glamor_pixmap_private *pixmap_priv)
|
||||
{
|
||||
pixmap_priv->base.picture = picture;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -35,7 +35,7 @@
|
|||
|
||||
static Bool
|
||||
_glamor_poly_fill_rect(DrawablePtr drawable,
|
||||
GCPtr gc, int nrect, xRectangle * prect, Bool fallback)
|
||||
GCPtr gc, int nrect, xRectangle *prect, Bool fallback)
|
||||
{
|
||||
int fullX1, fullX2, fullY1, fullY2;
|
||||
int xorg, yorg;
|
||||
|
@ -78,8 +78,7 @@ _glamor_poly_fill_rect(DrawablePtr drawable,
|
|||
pbox++;
|
||||
if (x1 >= x2 || y1 >= y2)
|
||||
continue;
|
||||
if (!glamor_fill(drawable, gc, x1, y1, x2 - x1,
|
||||
y2 - y1, fallback)) {
|
||||
if (!glamor_fill(drawable, gc, x1, y1, x2 - x1, y2 - y1, fallback)) {
|
||||
nrect++;
|
||||
goto fail;
|
||||
}
|
||||
|
@ -89,10 +88,9 @@ _glamor_poly_fill_rect(DrawablePtr drawable,
|
|||
ret = TRUE;
|
||||
goto done;
|
||||
|
||||
fail:
|
||||
fail:
|
||||
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(drawable)
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(drawable)
|
||||
&& glamor_ddx_fallback_check_gc(gc))
|
||||
goto done;
|
||||
|
||||
|
@ -107,21 +105,20 @@ fail:
|
|||
}
|
||||
ret = TRUE;
|
||||
|
||||
done:
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
glamor_poly_fill_rect(DrawablePtr drawable,
|
||||
GCPtr gc, int nrect, xRectangle * prect)
|
||||
GCPtr gc, int nrect, xRectangle *prect)
|
||||
{
|
||||
_glamor_poly_fill_rect(drawable, gc, nrect, prect, TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_poly_fill_rect_nf(DrawablePtr drawable,
|
||||
GCPtr gc, int nrect, xRectangle * prect)
|
||||
GCPtr gc, int nrect, xRectangle *prect)
|
||||
{
|
||||
return _glamor_poly_fill_rect(drawable, gc, nrect, prect, FALSE);
|
||||
}
|
||||
|
|
|
@ -54,9 +54,7 @@ _glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
|||
goto wide_line;
|
||||
}
|
||||
if (gc->lineStyle != LineSolid) {
|
||||
glamor_fallback
|
||||
("non-solid fill line style %d\n",
|
||||
gc->lineStyle);
|
||||
glamor_fallback("non-solid fill line style %d\n", gc->lineStyle);
|
||||
goto fail;
|
||||
}
|
||||
rects = malloc(sizeof(xRectangle) * (n - 1));
|
||||
|
@ -67,7 +65,8 @@ _glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
|||
if (mode == CoordModePrevious) {
|
||||
x2 = x1 + points[i + 1].x;
|
||||
y2 = y1 + points[i + 1].y;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
x2 = points[i + 1].x;
|
||||
y2 = points[i + 1].y;
|
||||
}
|
||||
|
@ -79,14 +78,16 @@ _glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
|||
if (x1 < x2) {
|
||||
rects[i].x = x1;
|
||||
rects[i].width = x2 - x1 + 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
rects[i].x = x2;
|
||||
rects[i].width = x1 - x2 + 1;
|
||||
}
|
||||
if (y1 < y2) {
|
||||
rects[i].y = y1;
|
||||
rects[i].height = y2 - y1 + 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
rects[i].y = y2;
|
||||
rects[i].height = y1 - y2 + 1;
|
||||
}
|
||||
|
@ -99,8 +100,7 @@ _glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
|||
return TRUE;
|
||||
|
||||
fail:
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(drawable)
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(drawable)
|
||||
&& glamor_ddx_fallback_check_gc(gc))
|
||||
return FALSE;
|
||||
|
||||
|
@ -112,8 +112,9 @@ _glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
|||
}
|
||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
} else {
|
||||
wide_line:
|
||||
}
|
||||
else {
|
||||
wide_line:
|
||||
/* fb calls mi functions in the lineWidth != 0 case. */
|
||||
fbPolyLine(drawable, gc, mode, n, points);
|
||||
}
|
||||
|
|
|
@ -32,8 +32,7 @@ static Bool
|
|||
_glamor_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
||||
DDXPointPtr ppt, Bool fallback)
|
||||
{
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_gc(pGC)
|
||||
if (!fallback && glamor_ddx_fallback_check_gc(pGC)
|
||||
&& glamor_ddx_fallback_check_pixmap(pDrawable))
|
||||
return FALSE;
|
||||
|
||||
|
@ -60,8 +59,7 @@ static Bool
|
|||
_glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
|
||||
xSegment *pSeg, Bool fallback)
|
||||
{
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_gc(pGC)
|
||||
if (!fallback && glamor_ddx_fallback_check_gc(pGC)
|
||||
&& glamor_ddx_fallback_check_pixmap(pDrawable))
|
||||
return FALSE;
|
||||
|
||||
|
@ -71,8 +69,7 @@ _glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
|
|||
}
|
||||
|
||||
void
|
||||
glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
|
||||
xSegment *pSeg)
|
||||
glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pSeg)
|
||||
{
|
||||
_glamor_poly_segment(pDrawable, pGC, nseg, pSeg, TRUE);
|
||||
}
|
||||
|
|
|
@ -27,20 +27,13 @@
|
|||
#ifndef GLAMOR_PRIV_H
|
||||
#define GLAMOR_PRIV_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "compiler.h"
|
||||
#include "dix-config.h"
|
||||
|
||||
#include <xorg-server.h>
|
||||
#ifndef DEBUG
|
||||
#define NDEBUG
|
||||
#endif
|
||||
#include "glamor.h"
|
||||
#include "compat-api.h"
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
|
||||
#ifdef GLAMOR_GLES2
|
||||
#include <GLES2/gl2.h>
|
||||
|
@ -61,19 +54,6 @@
|
|||
#include "glamor_debug.h"
|
||||
|
||||
#include <list.h>
|
||||
/* The list.h rename all the function to add xorg_ prefix.
|
||||
We add hack here to avoid the compile error when using
|
||||
old version xserver header file.
|
||||
These will be removed in future. */
|
||||
#ifndef xorg_list_entry
|
||||
#define xorg_list list
|
||||
#define xorg_list_for_each_entry list_for_each_entry
|
||||
#define xorg_list_for_each_entry_safe list_for_each_entry_safe
|
||||
#define xorg_list_del list_del
|
||||
#define xorg_list_add list_add
|
||||
#define xorg_list_append list_append
|
||||
#define xorg_list_init list_init
|
||||
#endif
|
||||
|
||||
struct glamor_pixmap_private;
|
||||
|
||||
|
@ -152,14 +132,12 @@ typedef struct {
|
|||
INT16 height;
|
||||
} glamor_composite_rect_t;
|
||||
|
||||
|
||||
enum glamor_vertex_type {
|
||||
GLAMOR_VERTEX_POS,
|
||||
GLAMOR_VERTEX_SOURCE,
|
||||
GLAMOR_VERTEX_MASK
|
||||
};
|
||||
|
||||
|
||||
enum gradient_shader {
|
||||
SHADER_GRADIENT_LINEAR,
|
||||
SHADER_GRADIENT_RADIAL,
|
||||
|
@ -250,7 +228,8 @@ typedef struct glamor_screen_private {
|
|||
int has_fbo_blit;
|
||||
int max_fbo_size;
|
||||
|
||||
struct xorg_list fbo_cache[CACHE_FORMAT_COUNT][CACHE_BUCKET_WCOUNT][CACHE_BUCKET_HCOUNT];
|
||||
struct xorg_list
|
||||
fbo_cache[CACHE_FORMAT_COUNT][CACHE_BUCKET_WCOUNT][CACHE_BUCKET_HCOUNT];
|
||||
unsigned long fbo_cache_watermark;
|
||||
|
||||
/* glamor_solid */
|
||||
|
@ -271,7 +250,7 @@ typedef struct glamor_screen_private {
|
|||
glamor_glyph_cache_t glyphCaches[GLAMOR_NUM_GLYPH_CACHE_FORMATS];
|
||||
Bool glyph_cache_initialized;
|
||||
|
||||
/* shaders to restore a texture to another texture.*/
|
||||
/* shaders to restore a texture to another texture. */
|
||||
GLint finish_access_prog[2];
|
||||
GLint finish_access_revert[2];
|
||||
GLint finish_access_swap_rb[2];
|
||||
|
@ -414,7 +393,7 @@ typedef struct glamor_pixmap_fbo {
|
|||
*
|
||||
**/
|
||||
|
||||
typedef struct glamor_pixmap_clipped_regions{
|
||||
typedef struct glamor_pixmap_clipped_regions {
|
||||
int block_idx;
|
||||
RegionPtr region;
|
||||
} glamor_pixmap_clipped_regions;
|
||||
|
@ -437,7 +416,7 @@ typedef struct glamor_pixmap_private_base {
|
|||
int drm_stride;
|
||||
glamor_screen_private *glamor_priv;
|
||||
PicturePtr picture;
|
||||
}glamor_pixmap_private_base_t;
|
||||
} glamor_pixmap_private_base_t;
|
||||
|
||||
/*
|
||||
* @base.fbo: current fbo.
|
||||
|
@ -464,7 +443,7 @@ typedef struct glamor_pixmap_private_large {
|
|||
int nbox;
|
||||
BoxPtr box_array;
|
||||
glamor_pixmap_fbo **fbo_array;
|
||||
}glamor_pixmap_private_large_t;
|
||||
} glamor_pixmap_private_large_t;
|
||||
|
||||
/*
|
||||
* @box: the relative coords in the corresponding fbo.
|
||||
|
@ -475,7 +454,7 @@ typedef struct glamor_pixmap_private_atlas {
|
|||
glamor_pixmap_private_base_t base;
|
||||
};
|
||||
BoxRec box;
|
||||
}glamor_pixmap_private_atlas_t;
|
||||
} glamor_pixmap_private_atlas_t;
|
||||
|
||||
typedef struct glamor_pixmap_private {
|
||||
union {
|
||||
|
@ -484,7 +463,7 @@ typedef struct glamor_pixmap_private {
|
|||
glamor_pixmap_private_large_t large;
|
||||
glamor_pixmap_private_atlas_t atlas;
|
||||
};
|
||||
}glamor_pixmap_private;
|
||||
} glamor_pixmap_private;
|
||||
|
||||
/*
|
||||
* Pixmap dynamic status, used by dynamic upload feature.
|
||||
|
@ -508,26 +487,21 @@ static inline glamor_screen_private *
|
|||
glamor_get_screen_private(ScreenPtr screen)
|
||||
{
|
||||
return (glamor_screen_private *)
|
||||
dixLookupPrivate(&screen->devPrivates,
|
||||
glamor_screen_private_key);
|
||||
dixLookupPrivate(&screen->devPrivates, glamor_screen_private_key);
|
||||
}
|
||||
|
||||
static inline void
|
||||
glamor_set_screen_private(ScreenPtr screen, glamor_screen_private *priv)
|
||||
{
|
||||
dixSetPrivate(&screen->devPrivates,
|
||||
glamor_screen_private_key,
|
||||
priv);
|
||||
dixSetPrivate(&screen->devPrivates, glamor_screen_private_key, priv);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static inline glamor_pixmap_private *
|
||||
glamor_get_pixmap_private(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_private *priv;
|
||||
priv = dixLookupPrivate(&pixmap->devPrivates,
|
||||
glamor_pixmap_private_key);
|
||||
|
||||
priv = dixLookupPrivate(&pixmap->devPrivates, glamor_pixmap_private_key);
|
||||
if (!priv) {
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_MEMORY);
|
||||
priv = dixLookupPrivate(&pixmap->devPrivates,
|
||||
|
@ -556,12 +530,15 @@ PixmapPtr glamor_get_drawable_pixmap(DrawablePtr drawable);
|
|||
|
||||
Bool glamor_destroy_pixmap(PixmapPtr pixmap);
|
||||
|
||||
glamor_pixmap_fbo* glamor_pixmap_detach_fbo(glamor_pixmap_private *pixmap_priv);
|
||||
glamor_pixmap_fbo *glamor_pixmap_detach_fbo(glamor_pixmap_private *
|
||||
pixmap_priv);
|
||||
void glamor_pixmap_attach_fbo(PixmapPtr pixmap, glamor_pixmap_fbo *fbo);
|
||||
glamor_pixmap_fbo * glamor_create_fbo_from_tex(glamor_screen_private *glamor_priv,
|
||||
int w, int h, GLenum format, GLint tex, int flag);
|
||||
glamor_pixmap_fbo * glamor_create_fbo(glamor_screen_private *glamor_priv,
|
||||
int w, int h, GLenum format, int flag);
|
||||
glamor_pixmap_fbo *glamor_create_fbo_from_tex(glamor_screen_private *
|
||||
glamor_priv, int w, int h,
|
||||
GLenum format, GLint tex,
|
||||
int flag);
|
||||
glamor_pixmap_fbo *glamor_create_fbo(glamor_screen_private *glamor_priv, int w,
|
||||
int h, GLenum format, int flag);
|
||||
void glamor_destroy_fbo(glamor_pixmap_fbo *fbo);
|
||||
void glamor_pixmap_destroy_fbo(glamor_pixmap_private *priv);
|
||||
void glamor_purge_fbo(glamor_pixmap_fbo *fbo);
|
||||
|
@ -571,16 +548,16 @@ void glamor_fini_pixmap_fbo(ScreenPtr screen);
|
|||
Bool glamor_pixmap_fbo_fixup(ScreenPtr screen, PixmapPtr pixmap);
|
||||
void glamor_fbo_expire(glamor_screen_private *glamor_priv);
|
||||
|
||||
glamor_pixmap_fbo *
|
||||
glamor_create_fbo_array(glamor_screen_private *glamor_priv,
|
||||
int w, int h, GLenum format, int flag,
|
||||
int block_w, int block_h, glamor_pixmap_private *);
|
||||
glamor_pixmap_fbo *glamor_create_fbo_array(glamor_screen_private *glamor_priv,
|
||||
int w, int h, GLenum format,
|
||||
int flag, int block_w, int block_h,
|
||||
glamor_pixmap_private *);
|
||||
|
||||
/* glamor_copyarea.c */
|
||||
RegionPtr
|
||||
|
||||
glamor_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc,
|
||||
int srcx, int srcy, int width, int height, int dstx,
|
||||
int dsty);
|
||||
int srcx, int srcy, int width, int height, int dstx, int dsty);
|
||||
void glamor_copy_n_to_n(DrawablePtr src, DrawablePtr dst, GCPtr gc,
|
||||
BoxPtr box, int nbox, int dx, int dy, Bool reverse,
|
||||
Bool upsidedown, Pixel bitplane, void *closure);
|
||||
|
@ -606,30 +583,28 @@ Bool glamor_stipple(PixmapPtr pixmap, PixmapPtr stipple,
|
|||
unsigned char alu, unsigned long planemask,
|
||||
unsigned long fg_pixel, unsigned long bg_pixel,
|
||||
int stipple_x, int stipple_y);
|
||||
GLint glamor_compile_glsl_prog(glamor_gl_dispatch * dispatch, GLenum type,
|
||||
GLint glamor_compile_glsl_prog(glamor_gl_dispatch *dispatch, GLenum type,
|
||||
const char *source);
|
||||
void glamor_link_glsl_prog(glamor_gl_dispatch * dispatch, GLint prog);
|
||||
void glamor_link_glsl_prog(glamor_gl_dispatch *dispatch, GLint prog);
|
||||
void glamor_get_color_4f_from_pixel(PixmapPtr pixmap,
|
||||
unsigned long fg_pixel,
|
||||
GLfloat * color);
|
||||
unsigned long fg_pixel, GLfloat *color);
|
||||
|
||||
int glamor_set_destination_pixmap(PixmapPtr pixmap);
|
||||
int glamor_set_destination_pixmap_priv(glamor_pixmap_private *
|
||||
pixmap_priv);
|
||||
int glamor_set_destination_pixmap_priv(glamor_pixmap_private *pixmap_priv);
|
||||
void glamor_set_destination_pixmap_fbo(glamor_pixmap_fbo *, int, int, int, int);
|
||||
|
||||
/* nc means no check. caller must ensure this pixmap has valid fbo.
|
||||
* usually use the GLAMOR_PIXMAP_PRIV_HAS_FBO firstly.
|
||||
* */
|
||||
void glamor_set_destination_pixmap_priv_nc(glamor_pixmap_private *
|
||||
pixmap_priv);
|
||||
void glamor_set_destination_pixmap_priv_nc(glamor_pixmap_private *pixmap_priv);
|
||||
|
||||
glamor_pixmap_fbo *
|
||||
glamor_es2_pixmap_read_prepare(PixmapPtr source, int x, int y, int w, int h, GLenum format,
|
||||
GLenum type, int no_alpha, int revert, int swap_rb);
|
||||
glamor_pixmap_fbo *glamor_es2_pixmap_read_prepare(PixmapPtr source, int x,
|
||||
int y, int w, int h,
|
||||
GLenum format, GLenum type,
|
||||
int no_alpha, int revert,
|
||||
int swap_rb);
|
||||
|
||||
Bool glamor_set_alu(struct glamor_gl_dispatch *dispatch,
|
||||
unsigned char alu);
|
||||
Bool glamor_set_alu(struct glamor_gl_dispatch *dispatch, unsigned char alu);
|
||||
Bool glamor_set_planemask(PixmapPtr pixmap, unsigned long planemask);
|
||||
Bool glamor_change_window_attributes(WindowPtr pWin, unsigned long mask);
|
||||
RegionPtr glamor_bitmap_to_region(PixmapPtr pixmap);
|
||||
|
@ -640,19 +615,14 @@ int glamor_gl_get_version(void);
|
|||
((major) * 256) \
|
||||
+ ((minor) * 1))
|
||||
|
||||
|
||||
|
||||
|
||||
/* glamor_fill.c */
|
||||
Bool glamor_fill(DrawablePtr drawable,
|
||||
GCPtr gc, int x, int y, int width, int height, Bool fallback);
|
||||
Bool glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
|
||||
unsigned char alu, unsigned long planemask,
|
||||
unsigned long fg_pixel);
|
||||
Bool
|
||||
glamor_solid_boxes(PixmapPtr pixmap,
|
||||
BoxPtr box, int nbox,
|
||||
unsigned long fg_pixel);
|
||||
Bool glamor_solid_boxes(PixmapPtr pixmap,
|
||||
BoxPtr box, int nbox, unsigned long fg_pixel);
|
||||
|
||||
/* glamor_fillspans.c */
|
||||
void glamor_fill_spans(DrawablePtr drawable,
|
||||
|
@ -663,12 +633,9 @@ void glamor_init_solid_shader(ScreenPtr screen);
|
|||
void glamor_fini_solid_shader(ScreenPtr screen);
|
||||
|
||||
/* glamor_getspans.c */
|
||||
void
|
||||
|
||||
glamor_get_spans(DrawablePtr drawable,
|
||||
int wmax,
|
||||
DDXPointPtr points,
|
||||
int *widths, int nspans, char *dst_start);
|
||||
void glamor_get_spans(DrawablePtr drawable,
|
||||
int wmax, DDXPointPtr points, int *widths,
|
||||
int nspans, char *dst_start);
|
||||
|
||||
/* glamor_glyphs.c */
|
||||
void glamor_glyphs_fini(ScreenPtr screen);
|
||||
|
@ -677,35 +644,28 @@ void glamor_glyphs(CARD8 op,
|
|||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc, int nlist, GlyphListPtr list,
|
||||
GlyphPtr * glyphs);
|
||||
INT16 ySrc, int nlist, GlyphListPtr list, GlyphPtr *glyphs);
|
||||
|
||||
/* glamor_setspans.c */
|
||||
void glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
||||
DDXPointPtr points, int *widths, int n, int sorted);
|
||||
|
||||
/* glamor_polyfillrect.c */
|
||||
void
|
||||
glamor_poly_fill_rect(DrawablePtr drawable,
|
||||
GCPtr gc, int nrect, xRectangle * prect);
|
||||
void glamor_poly_fill_rect(DrawablePtr drawable,
|
||||
GCPtr gc, int nrect, xRectangle *prect);
|
||||
|
||||
/* glamor_polylines.c */
|
||||
void
|
||||
|
||||
glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
||||
void glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
||||
DDXPointPtr points);
|
||||
|
||||
/* glamor_putimage.c */
|
||||
void
|
||||
|
||||
glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
||||
void glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
||||
int w, int h, int leftPad, int format, char *bits);
|
||||
void glamor_init_putimage_shaders(ScreenPtr screen);
|
||||
void glamor_fini_putimage_shaders(ScreenPtr screen);
|
||||
|
||||
/* glamor_render.c */
|
||||
Bool
|
||||
glamor_composite_clipped_region(CARD8 op,
|
||||
Bool glamor_composite_clipped_region(CARD8 op,
|
||||
PicturePtr source,
|
||||
PicturePtr mask,
|
||||
PicturePtr dest,
|
||||
|
@ -715,10 +675,8 @@ glamor_composite_clipped_region(CARD8 op,
|
|||
RegionPtr region,
|
||||
int x_source,
|
||||
int y_source,
|
||||
int x_mask,
|
||||
int y_mask,
|
||||
int x_dest,
|
||||
int y_dest);
|
||||
int x_mask, int y_mask,
|
||||
int x_dest, int y_dest);
|
||||
|
||||
void glamor_composite(CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
|
@ -735,12 +693,10 @@ void glamor_fini_composite_shaders(ScreenPtr screen);
|
|||
void glamor_composite_glyph_rects(CARD8 op,
|
||||
PicturePtr src, PicturePtr mask,
|
||||
PicturePtr dst, int nrect,
|
||||
glamor_composite_rect_t * rects);
|
||||
void glamor_composite_rects (CARD8 op,
|
||||
glamor_composite_rect_t *rects);
|
||||
void glamor_composite_rects(CARD8 op,
|
||||
PicturePtr pDst,
|
||||
xRenderColor *color,
|
||||
int nRect,
|
||||
xRectangle *rects);
|
||||
xRenderColor *color, int nRect, xRectangle *rects);
|
||||
void glamor_init_trapezoid_shader(ScreenPtr screen);
|
||||
void glamor_fini_trapezoid_shader(ScreenPtr screen);
|
||||
PicturePtr glamor_convert_gradient_picture(ScreenPtr screen,
|
||||
|
@ -756,12 +712,11 @@ Bool glamor_composite_choose_shader(CARD8 op,
|
|||
glamor_pixmap_private *mask_pixmap_priv,
|
||||
glamor_pixmap_private *dest_pixmap_priv,
|
||||
struct shader_key *s_key,
|
||||
glamor_composite_shader **shader,
|
||||
glamor_composite_shader ** shader,
|
||||
struct blendinfo *op_info,
|
||||
PictFormatShort *psaved_source_format);
|
||||
|
||||
void
|
||||
glamor_composite_set_shader_blend(glamor_pixmap_private *dest_priv,
|
||||
void glamor_composite_set_shader_blend(glamor_pixmap_private *dest_priv,
|
||||
struct shader_key *key,
|
||||
glamor_composite_shader *shader,
|
||||
struct blendinfo *op_info);
|
||||
|
@ -776,7 +731,7 @@ void glamor_emit_composite_vert(ScreenPtr screen,
|
|||
void glamor_trapezoids(CARD8 op,
|
||||
PicturePtr src, PicturePtr dst,
|
||||
PictFormatPtr mask_format, INT16 x_src, INT16 y_src,
|
||||
int ntrap, xTrapezoid * traps);
|
||||
int ntrap, xTrapezoid *traps);
|
||||
|
||||
/* glamor_tile.c */
|
||||
Bool glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
||||
|
@ -801,9 +756,7 @@ PicturePtr glamor_generate_radial_gradient_picture(ScreenPtr screen,
|
|||
PictFormatShort format);
|
||||
|
||||
/* glamor_triangles.c */
|
||||
void
|
||||
|
||||
glamor_triangles(CARD8 op,
|
||||
void glamor_triangles(CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
|
@ -813,6 +766,7 @@ glamor_triangles(CARD8 op,
|
|||
|
||||
void glamor_pixmap_init(ScreenPtr screen);
|
||||
void glamor_pixmap_fini(ScreenPtr screen);
|
||||
|
||||
/**
|
||||
* Download a pixmap's texture to cpu memory. If success,
|
||||
* One copy of current pixmap's texture will be put into
|
||||
|
@ -822,14 +776,12 @@ void glamor_pixmap_fini(ScreenPtr screen);
|
|||
* gl_tex must be 1. Used by glamor_prepare_access.
|
||||
*
|
||||
*/
|
||||
Bool glamor_download_pixmap_to_cpu(PixmapPtr pixmap,
|
||||
Bool glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access);
|
||||
|
||||
void *glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, int x, int y, int w,
|
||||
int h, int stride, void *bits, int pbo,
|
||||
glamor_access_t access);
|
||||
|
||||
void *
|
||||
glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, int x, int y, int w, int h,
|
||||
int stride, void *bits, int pbo, glamor_access_t access);
|
||||
|
||||
|
||||
/**
|
||||
* Restore a pixmap's data which is downloaded by
|
||||
* glamor_download_pixmap_to_cpu to its original
|
||||
|
@ -848,53 +800,51 @@ void glamor_restore_pixmap_to_texture(PixmapPtr pixmap);
|
|||
* the fbo has valid texture and attach to a valid fb.
|
||||
* If the fbo already has a valid glfbo then do nothing.
|
||||
*/
|
||||
Bool
|
||||
glamor_pixmap_ensure_fbo(PixmapPtr pixmap, GLenum format, int flag);
|
||||
Bool glamor_pixmap_ensure_fbo(PixmapPtr pixmap, GLenum format, int flag);
|
||||
|
||||
/**
|
||||
* Upload a pixmap to gl texture. Used by dynamic pixmap
|
||||
* uploading feature. The pixmap must be a software pixmap.
|
||||
* This function will change current FBO and current shaders.
|
||||
*/
|
||||
enum glamor_pixmap_status glamor_upload_pixmap_to_texture(PixmapPtr
|
||||
pixmap);
|
||||
enum glamor_pixmap_status glamor_upload_pixmap_to_texture(PixmapPtr pixmap);
|
||||
|
||||
Bool
|
||||
glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w, int h,
|
||||
int stride, void *bits, int pbo);
|
||||
Bool glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w,
|
||||
int h, int stride, void *bits,
|
||||
int pbo);
|
||||
|
||||
PixmapPtr
|
||||
glamor_get_sub_pixmap(PixmapPtr pixmap, int x, int y,
|
||||
PixmapPtr glamor_get_sub_pixmap(PixmapPtr pixmap, int x, int y,
|
||||
int w, int h, glamor_access_t access);
|
||||
void
|
||||
glamor_put_sub_pixmap(PixmapPtr sub_pixmap, PixmapPtr pixmap, int x, int y,
|
||||
void glamor_put_sub_pixmap(PixmapPtr sub_pixmap, PixmapPtr pixmap, int x, int y,
|
||||
int w, int h, glamor_access_t access);
|
||||
|
||||
glamor_pixmap_clipped_regions *
|
||||
glamor_compute_clipped_regions(glamor_pixmap_private *priv, RegionPtr region,
|
||||
int *clipped_nbox, int repeat_type,
|
||||
int reverse, int upsidedown);
|
||||
glamor_compute_clipped_regions(glamor_pixmap_private *priv,
|
||||
RegionPtr region, int *clipped_nbox,
|
||||
int repeat_type, int reverse,
|
||||
int upsidedown);
|
||||
|
||||
glamor_pixmap_clipped_regions *
|
||||
glamor_compute_clipped_regions_ext(glamor_pixmap_private *pixmap_priv,
|
||||
RegionPtr region,
|
||||
int *n_region,
|
||||
RegionPtr region, int *n_region,
|
||||
int inner_block_w, int inner_block_h,
|
||||
int reverse, int upsidedown);
|
||||
|
||||
glamor_pixmap_clipped_regions *
|
||||
glamor_compute_transform_clipped_regions(glamor_pixmap_private *priv, struct pixman_transform *transform,
|
||||
RegionPtr region, int *n_region, int dx, int dy, int repeat_type,
|
||||
int reverse, int upsidedown);
|
||||
glamor_compute_transform_clipped_regions(glamor_pixmap_private *priv,
|
||||
struct pixman_transform *transform,
|
||||
RegionPtr region,
|
||||
int *n_region, int dx, int dy,
|
||||
int repeat_type, int reverse,
|
||||
int upsidedown);
|
||||
|
||||
Bool
|
||||
glamor_composite_largepixmap_region(CARD8 op,
|
||||
Bool glamor_composite_largepixmap_region(CARD8 op,
|
||||
PicturePtr source,
|
||||
PicturePtr mask,
|
||||
PicturePtr dest,
|
||||
glamor_pixmap_private * source_pixmap_priv,
|
||||
glamor_pixmap_private * mask_pixmap_priv,
|
||||
glamor_pixmap_private * dest_pixmap_priv,
|
||||
glamor_pixmap_private *source_pixmap_priv,
|
||||
glamor_pixmap_private *mask_pixmap_priv,
|
||||
glamor_pixmap_private *dest_pixmap_priv,
|
||||
RegionPtr region, Bool force_clip,
|
||||
INT16 x_source,
|
||||
INT16 y_source,
|
||||
|
@ -903,30 +853,28 @@ glamor_composite_largepixmap_region(CARD8 op,
|
|||
INT16 x_dest, INT16 y_dest,
|
||||
CARD16 width, CARD16 height);
|
||||
|
||||
Bool
|
||||
glamor_get_transform_block_size(struct pixman_transform *transform,
|
||||
Bool glamor_get_transform_block_size(struct pixman_transform *transform,
|
||||
int block_w, int block_h,
|
||||
int *transformed_block_w,
|
||||
int *transformed_block_h);
|
||||
|
||||
void
|
||||
glamor_get_transform_extent_from_box(struct pixman_box32 *temp_box,
|
||||
void glamor_get_transform_extent_from_box(struct pixman_box32 *temp_box,
|
||||
struct pixman_transform *transform);
|
||||
|
||||
/**
|
||||
* Upload a picture to gl texture. Similar to the
|
||||
* glamor_upload_pixmap_to_texture. Used in rendering.
|
||||
**/
|
||||
enum glamor_pixmap_status
|
||||
glamor_upload_picture_to_texture(PicturePtr picture);
|
||||
enum glamor_pixmap_status glamor_upload_picture_to_texture(PicturePtr picture);
|
||||
|
||||
/**
|
||||
* Upload bits to a pixmap's texture. This function will
|
||||
* convert the bits to the specified format/type format
|
||||
* if the conversion is unavoidable.
|
||||
**/
|
||||
Bool glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format, GLenum type,
|
||||
int no_alpha, int revert, int swap_rb, void *bits);
|
||||
Bool glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format,
|
||||
GLenum type, int no_alpha, int revert,
|
||||
int swap_rb, void *bits);
|
||||
|
||||
/**
|
||||
* Destroy all the resources allocated on the uploading
|
||||
|
@ -938,67 +886,54 @@ int glamor_create_picture(PicturePtr picture);
|
|||
|
||||
void glamor_set_window_pixmap(WindowPtr pWindow, PixmapPtr pPixmap);
|
||||
|
||||
Bool
|
||||
glamor_prepare_access_picture(PicturePtr picture, glamor_access_t access);
|
||||
Bool glamor_prepare_access_picture(PicturePtr picture, glamor_access_t access);
|
||||
|
||||
void glamor_finish_access_picture(PicturePtr picture, glamor_access_t access);
|
||||
|
||||
void glamor_destroy_picture(PicturePtr picture);
|
||||
|
||||
/* fixup a fbo to the exact size as the pixmap. */
|
||||
Bool
|
||||
glamor_fixup_pixmap_priv(ScreenPtr screen, glamor_pixmap_private *pixmap_priv);
|
||||
Bool glamor_fixup_pixmap_priv(ScreenPtr screen,
|
||||
glamor_pixmap_private *pixmap_priv);
|
||||
|
||||
void
|
||||
glamor_picture_format_fixup(PicturePtr picture,
|
||||
glamor_pixmap_private * pixmap_priv);
|
||||
void glamor_picture_format_fixup(PicturePtr picture,
|
||||
glamor_pixmap_private *pixmap_priv);
|
||||
|
||||
void
|
||||
glamor_get_image(DrawablePtr pDrawable, int x, int y, int w, int h,
|
||||
void glamor_get_image(DrawablePtr pDrawable, int x, int y, int w, int h,
|
||||
unsigned int format, unsigned long planeMask, char *d);
|
||||
|
||||
void
|
||||
glamor_add_traps(PicturePtr pPicture,
|
||||
INT16 x_off,
|
||||
INT16 y_off, int ntrap, xTrap * traps);
|
||||
void glamor_add_traps(PicturePtr pPicture,
|
||||
INT16 x_off, INT16 y_off, int ntrap, xTrap *traps);
|
||||
|
||||
RegionPtr
|
||||
glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
|
||||
int srcx, int srcy, int w, int h, int dstx, int dsty,
|
||||
RegionPtr glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
|
||||
int srcx, int srcy, int w, int h,
|
||||
int dstx, int dsty,
|
||||
unsigned long bitPlane);
|
||||
|
||||
void
|
||||
glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
||||
void glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr * ppci, pointer pglyphBase);
|
||||
CharInfoPtr *ppci, void *pglyphBase);
|
||||
|
||||
void
|
||||
glamor_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
||||
void glamor_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr * ppci, pointer pglyphBase);
|
||||
CharInfoPtr *ppci, void *pglyphBase);
|
||||
|
||||
void
|
||||
glamor_push_pixels(GCPtr pGC, PixmapPtr pBitmap,
|
||||
void glamor_push_pixels(GCPtr pGC, PixmapPtr pBitmap,
|
||||
DrawablePtr pDrawable, int w, int h, int x, int y);
|
||||
|
||||
void
|
||||
glamor_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
||||
void glamor_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
||||
DDXPointPtr ppt);
|
||||
|
||||
void
|
||||
glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
|
||||
void glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
|
||||
xSegment *pSeg);
|
||||
|
||||
void
|
||||
glamor_poly_line(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
||||
void glamor_poly_line(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
||||
DDXPointPtr ppt);
|
||||
|
||||
void
|
||||
glamor_composite_rectangles(CARD8 op,
|
||||
void glamor_composite_rectangles(CARD8 op,
|
||||
PicturePtr dst,
|
||||
xRenderColor *color,
|
||||
int num_rects,
|
||||
xRectangle *rects);
|
||||
int num_rects, xRectangle *rects);
|
||||
|
||||
/* glamor_xv */
|
||||
typedef struct {
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
/** @file glamor_putaimge.c
|
||||
*
|
||||
* XPutImage implementation
|
||||
|
@ -37,23 +36,31 @@ void
|
|||
glamor_init_putimage_shaders(ScreenPtr screen)
|
||||
{
|
||||
#if 0
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
const char *xybitmap_vs =
|
||||
"uniform float x_bias;\n" "uniform float x_scale;\n"
|
||||
"uniform float y_bias;\n" "uniform float y_scale;\n"
|
||||
"varying vec2 bitmap_coords;\n" "void main()\n" "{\n"
|
||||
"uniform float x_bias;\n"
|
||||
"uniform float x_scale;\n"
|
||||
"uniform float y_bias;\n"
|
||||
"uniform float y_scale;\n"
|
||||
"varying vec2 bitmap_coords;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = vec4((gl_Vertex.x + x_bias) * x_scale,\n"
|
||||
" (gl_Vertex.y + y_bias) * y_scale,\n"
|
||||
" 0,\n"
|
||||
" 1);\n"
|
||||
" bitmap_coords = gl_MultiTexCoord0.xy;\n" "}\n";
|
||||
" bitmap_coords = gl_MultiTexCoord0.xy;\n"
|
||||
"}\n";
|
||||
const char *xybitmap_fs =
|
||||
"uniform vec4 fg, bg;\n" "varying vec2 bitmap_coords;\n"
|
||||
"uniform sampler2D bitmap_sampler;\n" "void main()\n" "{\n"
|
||||
"uniform vec4 fg, bg;\n"
|
||||
"varying vec2 bitmap_coords;\n"
|
||||
"uniform sampler2D bitmap_sampler;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" float bitmap_value = texture2D(bitmap_sampler,\n"
|
||||
" bitmap_coords).x;\n"
|
||||
" gl_FragColor = mix(bg, fg, bitmap_value);\n" "}\n";
|
||||
" gl_FragColor = mix(bg, fg, bitmap_value);\n"
|
||||
"}\n";
|
||||
GLint fs_prog, vs_prog, prog;
|
||||
GLint sampler_uniform_location;
|
||||
|
||||
|
@ -62,8 +69,7 @@ glamor_init_putimage_shaders(ScreenPtr screen)
|
|||
|
||||
prog = dispatch->glCreateProgram();
|
||||
vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, xybitmap_vs);
|
||||
fs_prog =
|
||||
glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, xybitmap_fs);
|
||||
fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, xybitmap_fs);
|
||||
dispatch->glAttachShader(prog, vs_prog);
|
||||
dispatch->glAttachShader(prog, fs_prog);
|
||||
glamor_link_glsl_prog(prog);
|
||||
|
@ -78,13 +84,13 @@ glamor_init_putimage_shaders(ScreenPtr screen)
|
|||
glamor_priv->put_image_xybitmap_bg_uniform_location =
|
||||
dispatch->glGetUniformLocation(prog, "bg");
|
||||
glamor_get_transform_uniform_locations(prog,
|
||||
&glamor_priv->put_image_xybitmap_transform);
|
||||
&glamor_priv->
|
||||
put_image_xybitmap_transform);
|
||||
glamor_priv->put_image_xybitmap_prog = prog;
|
||||
dispatch->glUseProgram(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* Do an XYBitmap putimage. The bits are byte-aligned rows of bitmap
|
||||
* data (where each row starts at a bit index of left_pad), and the
|
||||
* destination gets filled with the gc's fg color where the bitmap is set
|
||||
|
@ -110,7 +116,6 @@ y_flip(PixmapPtr pixmap, int y)
|
|||
return y;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
||||
int x, int y, int w, int h, int left_pad,
|
||||
|
@ -118,8 +123,7 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
|||
{
|
||||
ScreenPtr screen = drawable->pScreen;
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
float fg[4], bg[4];
|
||||
GLuint tex;
|
||||
unsigned int stride = PixmapBytePad(1, w + left_pad);
|
||||
|
@ -127,6 +131,7 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
|||
BoxPtr box;
|
||||
int nbox;
|
||||
float dest_coords[8];
|
||||
|
||||
const float bitmap_coords[8] = {
|
||||
0.0, 0.0,
|
||||
1.0, 0.0,
|
||||
|
@ -170,10 +175,8 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
|||
dispatch->glActiveTexture(GL_TEXTURE0);
|
||||
dispatch->glEnable(GL_TEXTURE_2D);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
dispatch->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
dispatch->glPixelStorei(GL_UNPACK_ROW_LENGTH, stride * 8);
|
||||
dispatch->glPixelStorei(GL_UNPACK_SKIP_PIXELS, left_pad);
|
||||
|
@ -194,8 +197,7 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
|||
|
||||
dispatch->glEnable(GL_SCISSOR_TEST);
|
||||
clip = fbGetCompositeClip(gc);
|
||||
for (nbox = REGION_NUM_RECTS(clip),
|
||||
box = REGION_RECTS(clip); nbox--; box++) {
|
||||
for (nbox = REGION_NUM_RECTS(clip), box = REGION_RECTS(clip); nbox--; box++) {
|
||||
int x1 = x;
|
||||
int y1 = y;
|
||||
int x2 = x + w;
|
||||
|
@ -230,10 +232,9 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
|||
glamor_set_planemask(pixmap, ~0);
|
||||
glamor_fallback(": to %p (%c)\n",
|
||||
drawable, glamor_get_drawable_location(drawable));
|
||||
fail:
|
||||
fail:
|
||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||
fbPutImage(drawable, gc, 1, x, y, w, h, left_pad, XYBitmap,
|
||||
bits);
|
||||
fbPutImage(drawable, gc, 1, x, y, w, h, left_pad, XYBitmap, bits);
|
||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
}
|
||||
|
@ -244,14 +245,13 @@ glamor_fini_putimage_shaders(ScreenPtr screen)
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
static Bool
|
||||
_glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
||||
int w, int h, int left_pad, int image_format, char *bits, Bool fallback)
|
||||
int w, int h, int left_pad, int image_format, char *bits,
|
||||
Bool fallback)
|
||||
{
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
RegionPtr clip;
|
||||
int x_off, y_off;
|
||||
Bool ret = FALSE;
|
||||
|
@ -302,19 +302,21 @@ _glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
|||
glamor_upload_sub_pixmap_to_texture(temp_pixmap, 0, 0, w, h,
|
||||
pixmap->devKind, bits, 0);
|
||||
|
||||
glamor_copy_area(&temp_pixmap->drawable, drawable, gc, 0, 0, w, h, x, y);
|
||||
glamor_copy_area(&temp_pixmap->drawable, drawable, gc, 0, 0, w, h, x,
|
||||
y);
|
||||
glamor_destroy_pixmap(temp_pixmap);
|
||||
} else
|
||||
glamor_upload_sub_pixmap_to_texture(pixmap, x + drawable->x + x_off, y + drawable->y + y_off,
|
||||
w, h, PixmapBytePad(w, depth), bits, 0);
|
||||
}
|
||||
else
|
||||
glamor_upload_sub_pixmap_to_texture(pixmap, x + drawable->x + x_off,
|
||||
y + drawable->y + y_off, w, h,
|
||||
PixmapBytePad(w, depth), bits, 0);
|
||||
ret = TRUE;
|
||||
goto done;
|
||||
|
||||
fail:
|
||||
fail:
|
||||
glamor_set_planemask(pixmap, ~0);
|
||||
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(&pixmap->drawable))
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(&pixmap->drawable))
|
||||
goto done;
|
||||
|
||||
glamor_fallback("to %p (%c)\n",
|
||||
|
@ -325,23 +327,23 @@ fail:
|
|||
GLAMOR_ACCESS_RW);
|
||||
if (sub_pixmap) {
|
||||
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,
|
||||
left_pad, image_format, bits);
|
||||
|
||||
glamor_put_sub_pixmap(sub_pixmap, pixmap,
|
||||
x + x_off + drawable->x,
|
||||
y + y_off + drawable->y,
|
||||
w, h, GLAMOR_ACCESS_RW);
|
||||
y + y_off + drawable->y, w, h, GLAMOR_ACCESS_RW);
|
||||
if (clip != NULL)
|
||||
pixman_region_translate (clip, x + drawable->x, y + drawable->y);
|
||||
} else
|
||||
pixman_region_translate(clip, x + drawable->x, y + drawable->y);
|
||||
}
|
||||
else
|
||||
fbPutImage(drawable, gc, depth, x, y, w, h,
|
||||
left_pad, image_format, bits);
|
||||
ret = TRUE;
|
||||
|
||||
done:
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -360,4 +362,3 @@ glamor_put_image_nf(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
|||
return _glamor_put_image(drawable, gc, depth, x, y, w, h,
|
||||
left_pad, image_format, bits, FALSE);
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -56,6 +56,7 @@ _glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
|||
for (i = 0; i < numPoints; i++) {
|
||||
|
||||
int n = REGION_NUM_RECTS(clip);
|
||||
|
||||
pbox = REGION_RECTS(clip);
|
||||
while (n--) {
|
||||
int x1 = points[i].x;
|
||||
|
@ -68,8 +69,10 @@ _glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
|||
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),
|
||||
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);
|
||||
|
@ -77,9 +80,8 @@ _glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
|||
ret = TRUE;
|
||||
goto done;
|
||||
|
||||
fail:
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(drawable))
|
||||
fail:
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(drawable))
|
||||
goto done;
|
||||
|
||||
glamor_fallback("to %p (%c)\n",
|
||||
|
@ -90,7 +92,7 @@ fail:
|
|||
}
|
||||
ret = TRUE;
|
||||
|
||||
done:
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -98,8 +100,7 @@ void
|
|||
glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
||||
DDXPointPtr points, int *widths, int n, int sorted)
|
||||
{
|
||||
_glamor_set_spans(drawable, gc, src, points,
|
||||
widths, n, sorted, TRUE);
|
||||
_glamor_set_spans(drawable, gc, src, points, widths, n, sorted, TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
|
|
|
@ -45,7 +45,8 @@ glamor_init_tile_shader(ScreenPtr screen)
|
|||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = v_position;\n"
|
||||
" tile_texture = v_texcoord0.xy;\n" "}\n";
|
||||
" tile_texture = v_texcoord0.xy;\n"
|
||||
"}\n";
|
||||
const char *tile_fs =
|
||||
GLAMOR_DEFAULT_PRECISION
|
||||
"varying vec2 tile_texture;\n"
|
||||
|
@ -65,27 +66,23 @@ glamor_init_tile_shader(ScreenPtr screen)
|
|||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
glamor_priv->tile_prog = dispatch->glCreateProgram();
|
||||
vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, tile_vs);
|
||||
fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
|
||||
tile_fs);
|
||||
fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER, tile_fs);
|
||||
dispatch->glAttachShader(glamor_priv->tile_prog, vs_prog);
|
||||
dispatch->glAttachShader(glamor_priv->tile_prog, fs_prog);
|
||||
|
||||
dispatch->glBindAttribLocation(glamor_priv->tile_prog,
|
||||
GLAMOR_VERTEX_POS, "v_position");
|
||||
dispatch->glBindAttribLocation(glamor_priv->tile_prog,
|
||||
GLAMOR_VERTEX_SOURCE,
|
||||
"v_texcoord0");
|
||||
GLAMOR_VERTEX_SOURCE, "v_texcoord0");
|
||||
glamor_link_glsl_prog(dispatch, glamor_priv->tile_prog);
|
||||
|
||||
sampler_uniform_location =
|
||||
dispatch->glGetUniformLocation(glamor_priv->tile_prog,
|
||||
"sampler");
|
||||
dispatch->glGetUniformLocation(glamor_priv->tile_prog, "sampler");
|
||||
dispatch->glUseProgram(glamor_priv->tile_prog);
|
||||
dispatch->glUniform1i(sampler_uniform_location, 0);
|
||||
|
||||
glamor_priv->tile_wh =
|
||||
dispatch->glGetUniformLocation(glamor_priv->tile_prog,
|
||||
"wh");
|
||||
dispatch->glGetUniformLocation(glamor_priv->tile_prog, "wh");
|
||||
dispatch->glUseProgram(0);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
}
|
||||
|
@ -104,12 +101,10 @@ glamor_fini_tile_shader(ScreenPtr screen)
|
|||
|
||||
static void
|
||||
_glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
||||
int x, int y, int width, int height,
|
||||
int tile_x, int tile_y)
|
||||
int x, int y, int width, int height, int tile_x, int tile_y)
|
||||
{
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_gl_dispatch *dispatch;
|
||||
int x1 = x;
|
||||
int x2 = x + width;
|
||||
|
@ -125,31 +120,24 @@ _glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
|||
glamor_pixmap_private *src_pixmap_priv;
|
||||
glamor_pixmap_private *dst_pixmap_priv;
|
||||
float wh[4];
|
||||
|
||||
src_pixmap_priv = glamor_get_pixmap_private(tile);
|
||||
dst_pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
glamor_set_destination_pixmap_priv_nc(dst_pixmap_priv);
|
||||
pixmap_priv_get_dest_scale(dst_pixmap_priv, &dst_xscale, &dst_yscale);
|
||||
pixmap_priv_get_scale(src_pixmap_priv, &src_xscale,
|
||||
&src_yscale);
|
||||
pixmap_priv_get_scale(src_pixmap_priv, &src_xscale, &src_yscale);
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glUseProgram(glamor_priv->tile_prog);
|
||||
|
||||
glamor_pixmap_fbo_fix_wh_ratio(wh, src_pixmap_priv);
|
||||
dispatch->glUniform2fv(glamor_priv->tile_wh, 1, wh);
|
||||
dispatch->glActiveTexture(GL_TEXTURE0);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D,
|
||||
src_pixmap_priv->base.fbo->tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MIN_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MAG_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
|
||||
GL_REPEAT);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
|
||||
GL_REPEAT);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv->base.fbo->tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
#ifndef GLAMOR_GLES2
|
||||
dispatch->glEnable(GL_TEXTURE_2D);
|
||||
#endif
|
||||
|
@ -157,24 +145,19 @@ _glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
|||
(src_pixmap_priv, RepeatNormal,
|
||||
src_xscale, src_yscale,
|
||||
tile_x1, tile_y1,
|
||||
tile_x2, tile_y2,
|
||||
glamor_priv->yInverted,
|
||||
source_texcoords);
|
||||
tile_x2, tile_y2, glamor_priv->yInverted, source_texcoords);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
|
||||
GL_FLOAT, GL_FALSE,
|
||||
2 * sizeof(float),
|
||||
source_texcoords);
|
||||
2 * sizeof(float), source_texcoords);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
|
||||
glamor_set_normalize_vcoords(dst_pixmap_priv, dst_xscale, dst_yscale,
|
||||
x1, y1,
|
||||
x2, y2,
|
||||
glamor_priv->yInverted, vertices);
|
||||
x2, y2, glamor_priv->yInverted, vertices);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
vertices);
|
||||
GL_FALSE, 2 * sizeof(float), vertices);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
|
@ -193,12 +176,10 @@ _glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
|||
Bool
|
||||
glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
||||
int x, int y, int width, int height,
|
||||
unsigned char alu, unsigned long planemask,
|
||||
int tile_x, int tile_y)
|
||||
unsigned char alu, unsigned long planemask, int tile_x, int tile_y)
|
||||
{
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_pixmap_private *dst_pixmap_priv;
|
||||
glamor_pixmap_private *src_pixmap_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
|
@ -245,37 +226,42 @@ glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
|||
box.y2 = y + height;
|
||||
RegionInitBoxes(®ion, &box, 1);
|
||||
clipped_dst_regions = glamor_compute_clipped_regions(dst_pixmap_priv,
|
||||
®ion, &n_dst_region, 0, 0, 0);
|
||||
for(i = 0; i < n_dst_region; i++)
|
||||
{
|
||||
®ion,
|
||||
&n_dst_region, 0,
|
||||
0, 0);
|
||||
for (i = 0; i < n_dst_region; i++) {
|
||||
int n_src_region;
|
||||
glamor_pixmap_clipped_regions *clipped_src_regions;
|
||||
BoxPtr current_boxes;
|
||||
int n_current_boxes;
|
||||
|
||||
SET_PIXMAP_FBO_CURRENT(dst_pixmap_priv, clipped_dst_regions[i].block_idx);
|
||||
SET_PIXMAP_FBO_CURRENT(dst_pixmap_priv,
|
||||
clipped_dst_regions[i].block_idx);
|
||||
|
||||
if (src_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
RegionTranslate(clipped_dst_regions[i].region,
|
||||
tile_x - x, tile_y - y);
|
||||
DEBUGF("tiled a large src pixmap. %dx%d \n", tile->drawable.width, tile->drawable.height);
|
||||
clipped_src_regions = glamor_compute_clipped_regions(src_pixmap_priv,
|
||||
clipped_dst_regions[i].region,
|
||||
&n_src_region, 1, 0, 0);
|
||||
DEBUGF("tiled a large src pixmap. %dx%d \n",
|
||||
tile->drawable.width, tile->drawable.height);
|
||||
clipped_src_regions =
|
||||
glamor_compute_clipped_regions(src_pixmap_priv,
|
||||
clipped_dst_regions[i].
|
||||
region, &n_src_region, 1, 0,
|
||||
0);
|
||||
DEBUGF("got %d src regions %d \n", n_src_region);
|
||||
for (j = 0; j < n_src_region; j++)
|
||||
{
|
||||
for (j = 0; j < n_src_region; j++) {
|
||||
|
||||
SET_PIXMAP_FBO_CURRENT(src_pixmap_priv, clipped_src_regions[j].block_idx);
|
||||
SET_PIXMAP_FBO_CURRENT(src_pixmap_priv,
|
||||
clipped_src_regions[j].block_idx);
|
||||
|
||||
RegionTranslate(clipped_src_regions[j].region,
|
||||
x - tile_x,
|
||||
y - tile_y);
|
||||
x - tile_x, y - tile_y);
|
||||
current_boxes = RegionRects(clipped_src_regions[j].region);
|
||||
n_current_boxes = RegionNumRects(clipped_src_regions[j].region);
|
||||
for(k = 0; k < n_current_boxes; k++)
|
||||
{
|
||||
DEBUGF("Tile on %d %d %d %d dst block id %d tile block id %d tilex %d tiley %d\n",
|
||||
n_current_boxes =
|
||||
RegionNumRects(clipped_src_regions[j].region);
|
||||
for (k = 0; k < n_current_boxes; k++) {
|
||||
DEBUGF
|
||||
("Tile on %d %d %d %d dst block id %d tile block id %d tilex %d tiley %d\n",
|
||||
current_boxes[k].x1, current_boxes[k].y1,
|
||||
current_boxes[k].x2 - current_boxes[k].x1,
|
||||
current_boxes[k].y2 - current_boxes[k].y1,
|
||||
|
@ -295,11 +281,11 @@ glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
|||
RegionDestroy(clipped_src_regions[j].region);
|
||||
}
|
||||
free(clipped_src_regions);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
current_boxes = RegionRects(clipped_dst_regions[i].region);
|
||||
n_current_boxes = RegionNumRects(clipped_dst_regions[i].region);
|
||||
for(k = 0; k < n_current_boxes; k++)
|
||||
{
|
||||
for (k = 0; k < n_current_boxes; k++) {
|
||||
_glamor_tile(pixmap, tile,
|
||||
current_boxes[k].x1, current_boxes[k].y1,
|
||||
current_boxes[k].x2 - current_boxes[k].x1,
|
||||
|
@ -319,7 +305,7 @@ glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
|||
glamor_set_alu(dispatch, GXcopy);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
return TRUE;
|
||||
fail:
|
||||
fail:
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
|
|
|
@ -37,22 +37,24 @@
|
|||
#include "fbpict.h"
|
||||
|
||||
static xFixed
|
||||
_glamor_linefixedX (xLineFixed *l, xFixed y, Bool ceil)
|
||||
_glamor_linefixedX(xLineFixed *l, xFixed y, Bool ceil)
|
||||
{
|
||||
xFixed dx = l->p2.x - l->p1.x;
|
||||
xFixed_32_32 ex = (xFixed_32_32) (y - l->p1.y) * dx;
|
||||
xFixed dy = l->p2.y - l->p1.y;
|
||||
|
||||
if (ceil)
|
||||
ex += (dy - 1);
|
||||
return l->p1.x + (xFixed) (ex / dy);
|
||||
}
|
||||
|
||||
static xFixed
|
||||
_glamor_linefixedY (xLineFixed *l, xFixed x, Bool ceil)
|
||||
_glamor_linefixedY(xLineFixed *l, xFixed x, Bool ceil)
|
||||
{
|
||||
xFixed dy = l->p2.y - l->p1.y;
|
||||
xFixed_32_32 ey = (xFixed_32_32) (x - l->p1.x) * dy;
|
||||
xFixed dx = l->p2.x - l->p1.x;
|
||||
|
||||
if (ceil)
|
||||
ey += (dx - 1);
|
||||
return l->p1.y + (xFixed) (ey / dx);
|
||||
|
@ -73,7 +75,7 @@ _glamor_linefixedY (xLineFixed *l, xFixed x, Bool ceil)
|
|||
&& point[1] <= IntToxFixed(rect->y2))
|
||||
|
||||
static xFixed
|
||||
_glamor_lines_crossfixedY (xLineFixed *l, xLineFixed *r)
|
||||
_glamor_lines_crossfixedY(xLineFixed *l, xLineFixed *r)
|
||||
{
|
||||
xFixed dx1 = l->p2.x - l->p1.x;
|
||||
xFixed dx2 = r->p2.x - r->p1.x;
|
||||
|
@ -85,32 +87,35 @@ _glamor_lines_crossfixedY (xLineFixed *l, xLineFixed *r)
|
|||
xFixed_32_32 dividend3;
|
||||
xFixed_32_32 divisor;
|
||||
|
||||
tmp = (xFixed_32_32) dx1 * dy2;
|
||||
tmp = (xFixed_32_32) dx1 *dy2;
|
||||
|
||||
dividend2 = (tmp >> 32) * l->p1.y;
|
||||
tmp = (xFixed_32_32) dy1 * dx2;
|
||||
tmp = (xFixed_32_32) dy1 *dx2;
|
||||
|
||||
dividend3 = (tmp >> 32) * r->p1.y;
|
||||
divisor = ((xFixed_32_32) dx1 * (xFixed_32_32) dy2
|
||||
- (xFixed_32_32) dy1 * (xFixed_32_32) dx2) >> 32;
|
||||
|
||||
if (divisor)
|
||||
return (xFixed)((dividend2 - dividend1 - dividend3) / divisor);
|
||||
return (xFixed) ((dividend2 - dividend1 - dividend3) / divisor);
|
||||
|
||||
return 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
static Bool
|
||||
point_inside_trapezoid(int point[2], xTrapezoid * trap, xFixed cut_y)
|
||||
point_inside_trapezoid(int point[2], xTrapezoid *trap, xFixed cut_y)
|
||||
{
|
||||
int ret = TRUE;
|
||||
int tmp;
|
||||
|
||||
if (point[1] > trap->bottom) {
|
||||
ret = FALSE;
|
||||
if (DEBUG_CLIP_VTX) {
|
||||
ErrorF("Out of Trap bottom, point[1] = %d(0x%x)), "
|
||||
"bottom = %d(0x%x)\n",
|
||||
(unsigned int)xFixedToInt(point[1]), point[1],
|
||||
(unsigned int)xFixedToInt(trap->bottom),
|
||||
(unsigned int)trap->bottom);
|
||||
(unsigned int) xFixedToInt(point[1]), point[1],
|
||||
(unsigned int) xFixedToInt(trap->bottom),
|
||||
(unsigned int) trap->bottom);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -121,15 +126,15 @@ point_inside_trapezoid(int point[2], xTrapezoid * trap, xFixed cut_y)
|
|||
if (DEBUG_CLIP_VTX) {
|
||||
ErrorF("Out of Trap top, point[1] = %d(0x%x)), "
|
||||
"top = %d(0x%x)\n",
|
||||
(unsigned int)xFixedToInt(point[1]), point[1],
|
||||
(unsigned int)xFixedToInt(trap->top),
|
||||
(unsigned int)trap->top);
|
||||
(unsigned int) xFixedToInt(point[1]), point[1],
|
||||
(unsigned int) xFixedToInt(trap->top),
|
||||
(unsigned int) trap->top);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
tmp = _glamor_linefixedX (&trap->left, point[1], FALSE);
|
||||
tmp = _glamor_linefixedX(&trap->left, point[1], FALSE);
|
||||
if (point[0] < tmp) {
|
||||
ret = FALSE;
|
||||
|
||||
|
@ -137,7 +142,8 @@ point_inside_trapezoid(int point[2], xTrapezoid * trap, xFixed cut_y)
|
|||
abs(point[1] - trap->top) < pixman_fixed_1_minus_e &&
|
||||
tmp - point[0] < pixman_fixed_1_minus_e) {
|
||||
ret = TRUE;
|
||||
} else if (abs(cut_y - trap->bottom) < pixman_fixed_1_minus_e &&
|
||||
}
|
||||
else if (abs(cut_y - trap->bottom) < pixman_fixed_1_minus_e &&
|
||||
point[1] - trap->bottom < pixman_fixed_1_minus_e &&
|
||||
tmp - point[0] < pixman_fixed_1_minus_e) {
|
||||
ret = TRUE;
|
||||
|
@ -146,15 +152,15 @@ point_inside_trapezoid(int point[2], xTrapezoid * trap, xFixed cut_y)
|
|||
if (DEBUG_CLIP_VTX && !ret) {
|
||||
ErrorF("Out of Trap left, point[0] = %d(0x%x)), "
|
||||
"left = %d(0x%x)\n",
|
||||
(unsigned int)xFixedToInt(point[0]), point[0],
|
||||
(unsigned int)xFixedToInt(tmp), (unsigned int)tmp);
|
||||
(unsigned int) xFixedToInt(point[0]), point[0],
|
||||
(unsigned int) xFixedToInt(tmp), (unsigned int) tmp);
|
||||
}
|
||||
|
||||
if (!ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
tmp = _glamor_linefixedX (&trap->right, point[1], TRUE);
|
||||
tmp = _glamor_linefixedX(&trap->right, point[1], TRUE);
|
||||
if (point[0] > tmp) {
|
||||
ret = FALSE;
|
||||
|
||||
|
@ -162,7 +168,8 @@ point_inside_trapezoid(int point[2], xTrapezoid * trap, xFixed cut_y)
|
|||
abs(point[1] - trap->top) < pixman_fixed_1_minus_e &&
|
||||
point[0] - tmp < pixman_fixed_1_minus_e) {
|
||||
ret = TRUE;
|
||||
} else if (abs(cut_y - trap->bottom) < pixman_fixed_1_minus_e &&
|
||||
}
|
||||
else if (abs(cut_y - trap->bottom) < pixman_fixed_1_minus_e &&
|
||||
abs(point[1] - trap->bottom) < pixman_fixed_1_minus_e &&
|
||||
point[0] - tmp < pixman_fixed_1_minus_e) {
|
||||
ret = TRUE;
|
||||
|
@ -171,8 +178,8 @@ point_inside_trapezoid(int point[2], xTrapezoid * trap, xFixed cut_y)
|
|||
if (DEBUG_CLIP_VTX && !ret) {
|
||||
ErrorF("Out of Trap right, point[0] = %d(0x%x)), "
|
||||
"right = %d(0x%x)\n",
|
||||
(unsigned int)xFixedToInt(point[0]), point[0],
|
||||
(unsigned int)xFixedToInt(tmp), (unsigned int)tmp);
|
||||
(unsigned int) xFixedToInt(point[0]), point[0],
|
||||
(unsigned int) xFixedToInt(tmp), (unsigned int) tmp);
|
||||
}
|
||||
|
||||
if (!ret)
|
||||
|
@ -188,19 +195,15 @@ glamor_emit_composite_triangle(ScreenPtr screen,
|
|||
const float *mask_coords,
|
||||
const float *dst_coords)
|
||||
{
|
||||
glamor_emit_composite_vert(screen, src_coords, mask_coords,
|
||||
dst_coords, 0);
|
||||
glamor_emit_composite_vert(screen, src_coords, mask_coords,
|
||||
dst_coords, 1);
|
||||
glamor_emit_composite_vert(screen, src_coords, mask_coords,
|
||||
dst_coords, 2);
|
||||
glamor_emit_composite_vert(screen, src_coords, mask_coords, dst_coords, 0);
|
||||
glamor_emit_composite_vert(screen, src_coords, mask_coords, dst_coords, 1);
|
||||
glamor_emit_composite_vert(screen, src_coords, mask_coords, dst_coords, 2);
|
||||
}
|
||||
|
||||
static void
|
||||
glamor_flush_composite_triangles(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_gl_dispatch *dispatch;
|
||||
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
|
@ -222,7 +225,7 @@ glamor_flush_composite_triangles(ScreenPtr screen)
|
|||
}
|
||||
|
||||
static Bool
|
||||
_glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
|
||||
_glamor_clip_trapezoid_vertex(xTrapezoid *trap, BoxPtr pbox,
|
||||
int vertex[6], int *num)
|
||||
{
|
||||
xFixed edge_cross_y = 0xFFFFFFFF;
|
||||
|
@ -239,26 +242,27 @@ _glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
|
|||
int right_cut_right[2];
|
||||
int right_cut_bottom[2];
|
||||
int tmp[2];
|
||||
int tmp_vtx[20*2];
|
||||
int tmp_vtx[20 * 2];
|
||||
float tmp_vtx_slope[20];
|
||||
BoxRec trap_bound;
|
||||
int i = 0;
|
||||
int vertex_num = 0;
|
||||
|
||||
if (DEBUG_CLIP_VTX) {
|
||||
ErrorF("The parameter of xTrapezoid is:\ntop: %d 0x%x\tbottom: %d 0x%x\n"
|
||||
ErrorF
|
||||
("The parameter of xTrapezoid is:\ntop: %d 0x%x\tbottom: %d 0x%x\n"
|
||||
"left: p1 (%d 0x%x, %d 0x%x)\tp2 (%d 0x%x, %d 0x%x)\n"
|
||||
"right: p1 (%d 0x%x, %d 0x%x)\tp2 (%d 0x%x, %d 0x%x)\n",
|
||||
xFixedToInt(trap->top), (unsigned int)trap->top,
|
||||
xFixedToInt(trap->bottom), (unsigned int)trap->bottom,
|
||||
xFixedToInt(trap->left.p1.x), (unsigned int)trap->left.p1.x,
|
||||
xFixedToInt(trap->left.p1.y), (unsigned int)trap->left.p1.y,
|
||||
xFixedToInt(trap->left.p2.x), (unsigned int)trap->left.p2.x,
|
||||
xFixedToInt(trap->left.p2.y), (unsigned int)trap->left.p2.y,
|
||||
xFixedToInt(trap->right.p1.x), (unsigned int)trap->right.p1.x,
|
||||
xFixedToInt(trap->right.p1.y), (unsigned int)trap->right.p1.y,
|
||||
xFixedToInt(trap->right.p2.x), (unsigned int)trap->right.p2.x,
|
||||
xFixedToInt(trap->right.p2.y), (unsigned int)trap->right.p2.y);
|
||||
xFixedToInt(trap->top), (unsigned int) trap->top,
|
||||
xFixedToInt(trap->bottom), (unsigned int) trap->bottom,
|
||||
xFixedToInt(trap->left.p1.x), (unsigned int) trap->left.p1.x,
|
||||
xFixedToInt(trap->left.p1.y), (unsigned int) trap->left.p1.y,
|
||||
xFixedToInt(trap->left.p2.x), (unsigned int) trap->left.p2.x,
|
||||
xFixedToInt(trap->left.p2.y), (unsigned int) trap->left.p2.y,
|
||||
xFixedToInt(trap->right.p1.x), (unsigned int) trap->right.p1.x,
|
||||
xFixedToInt(trap->right.p1.y), (unsigned int) trap->right.p1.y,
|
||||
xFixedToInt(trap->right.p2.x), (unsigned int) trap->right.p2.x,
|
||||
xFixedToInt(trap->right.p2.y), (unsigned int) trap->right.p2.y);
|
||||
}
|
||||
|
||||
miTrapezoidBounds(1, trap, &trap_bound);
|
||||
|
@ -335,14 +339,14 @@ _glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
|
|||
}
|
||||
|
||||
/*Trap's right edge cut right edge. */
|
||||
if((!IS_TRAP_EDGE_VERTICAL((&trap->left))) ||
|
||||
if ((!IS_TRAP_EDGE_VERTICAL((&trap->left))) ||
|
||||
(!IS_TRAP_EDGE_VERTICAL((&trap->right)))) {
|
||||
edge_cross_y = _glamor_lines_crossfixedY((&trap->left), (&trap->right));
|
||||
if (DEBUG_CLIP_VTX) {
|
||||
ErrorF("Trap's left edge cut right edge at %d(0x%x), "
|
||||
"trap_top = %x, trap_bottom = %x\n",
|
||||
xFixedToInt(edge_cross_y), edge_cross_y,
|
||||
(unsigned int)trap->top, (unsigned int)trap->bottom);
|
||||
(unsigned int) trap->top, (unsigned int) trap->bottom);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -381,32 +385,40 @@ _glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
|
|||
/*Trap's left edge cut Rect. */
|
||||
if (DEBUG_CLIP_VTX)
|
||||
ErrorF("Trap's left edge cut Rect\n");
|
||||
CACULATE_CUT_VERTEX(left_cut_top, 1, FALSE, IntToxFixed(pbox->y1), (&trap->left));
|
||||
CACULATE_CUT_VERTEX(left_cut_top, 1, FALSE, IntToxFixed(pbox->y1),
|
||||
(&trap->left));
|
||||
ADD_VERTEX_IF_INSIDE(left_cut_top);
|
||||
if (!IS_TRAP_EDGE_VERTICAL((&trap->left))) {
|
||||
CACULATE_CUT_VERTEX(left_cut_left, 0, FALSE, IntToxFixed(pbox->x1), (&trap->left));
|
||||
CACULATE_CUT_VERTEX(left_cut_left, 0, FALSE, IntToxFixed(pbox->x1),
|
||||
(&trap->left));
|
||||
ADD_VERTEX_IF_INSIDE(left_cut_left);
|
||||
}
|
||||
CACULATE_CUT_VERTEX(left_cut_bottom, 1, FALSE, IntToxFixed(pbox->y2), (&trap->left));
|
||||
CACULATE_CUT_VERTEX(left_cut_bottom, 1, FALSE, IntToxFixed(pbox->y2),
|
||||
(&trap->left));
|
||||
ADD_VERTEX_IF_INSIDE(left_cut_bottom);
|
||||
if (!IS_TRAP_EDGE_VERTICAL((&trap->left))) {
|
||||
CACULATE_CUT_VERTEX(left_cut_right, 0, FALSE, IntToxFixed(pbox->x2), (&trap->left));
|
||||
CACULATE_CUT_VERTEX(left_cut_right, 0, FALSE, IntToxFixed(pbox->x2),
|
||||
(&trap->left));
|
||||
ADD_VERTEX_IF_INSIDE(left_cut_right);
|
||||
}
|
||||
|
||||
/*Trap's right edge cut Rect. */
|
||||
if (DEBUG_CLIP_VTX)
|
||||
ErrorF("Trap's right edge cut Rect\n");
|
||||
CACULATE_CUT_VERTEX(right_cut_top, 1, TRUE, IntToxFixed(pbox->y1), (&trap->right));
|
||||
CACULATE_CUT_VERTEX(right_cut_top, 1, TRUE, IntToxFixed(pbox->y1),
|
||||
(&trap->right));
|
||||
ADD_VERTEX_IF_INSIDE(right_cut_top);
|
||||
if (!IS_TRAP_EDGE_VERTICAL((&trap->right))) {
|
||||
CACULATE_CUT_VERTEX(right_cut_left, 0, TRUE, IntToxFixed(pbox->x1), (&trap->right));
|
||||
CACULATE_CUT_VERTEX(right_cut_left, 0, TRUE, IntToxFixed(pbox->x1),
|
||||
(&trap->right));
|
||||
ADD_VERTEX_IF_INSIDE(right_cut_left);
|
||||
}
|
||||
CACULATE_CUT_VERTEX(right_cut_bottom, 1, TRUE, IntToxFixed(pbox->y2), (&trap->right));
|
||||
CACULATE_CUT_VERTEX(right_cut_bottom, 1, TRUE, IntToxFixed(pbox->y2),
|
||||
(&trap->right));
|
||||
ADD_VERTEX_IF_INSIDE(right_cut_bottom);
|
||||
if (!IS_TRAP_EDGE_VERTICAL((&trap->right))) {
|
||||
CACULATE_CUT_VERTEX(right_cut_right, 0, TRUE, IntToxFixed(pbox->x2), (&trap->right));
|
||||
CACULATE_CUT_VERTEX(right_cut_right, 0, TRUE, IntToxFixed(pbox->x2),
|
||||
(&trap->right));
|
||||
ADD_VERTEX_IF_INSIDE(right_cut_right);
|
||||
}
|
||||
|
||||
|
@ -449,7 +461,7 @@ _glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
|
|||
if (DEBUG_CLIP_VTX) {
|
||||
ErrorF("\nThe candidate vertex number is %d\n", vertex_num / 2);
|
||||
for (i = 0; i < vertex_num / 2; i++) {
|
||||
ErrorF("(%d, %d) ", tmp_vtx[2*i], tmp_vtx[2*i + 1]);
|
||||
ErrorF("(%d, %d) ", tmp_vtx[2 * i], tmp_vtx[2 * i + 1]);
|
||||
}
|
||||
ErrorF("\n");
|
||||
}
|
||||
|
@ -457,16 +469,17 @@ _glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
|
|||
/* Sort the vertex by X and then Y. */
|
||||
for (i = 0; i < vertex_num / 2; i++) {
|
||||
int j;
|
||||
|
||||
for (j = 0; j < vertex_num / 2 - i - 1; j++) {
|
||||
if (tmp_vtx[2*j] > tmp_vtx[2*(j+1)]
|
||||
|| (tmp_vtx[2*j] == tmp_vtx[2*(j+1)]
|
||||
&& tmp_vtx[2*j + 1] > tmp_vtx[2*(j+1) + 1])) {
|
||||
tmp[0] = tmp_vtx[2*j];
|
||||
tmp[1] = tmp_vtx[2*j + 1];
|
||||
tmp_vtx[2*j] = tmp_vtx[2*(j+1)];
|
||||
tmp_vtx[2*j + 1] = tmp_vtx[2*(j+1) + 1];
|
||||
tmp_vtx[2*(j+1)] = tmp[0];
|
||||
tmp_vtx[2*(j+1) + 1] = tmp[1];
|
||||
if (tmp_vtx[2 * j] > tmp_vtx[2 * (j + 1)]
|
||||
|| (tmp_vtx[2 * j] == tmp_vtx[2 * (j + 1)]
|
||||
&& tmp_vtx[2 * j + 1] > tmp_vtx[2 * (j + 1) + 1])) {
|
||||
tmp[0] = tmp_vtx[2 * j];
|
||||
tmp[1] = tmp_vtx[2 * j + 1];
|
||||
tmp_vtx[2 * j] = tmp_vtx[2 * (j + 1)];
|
||||
tmp_vtx[2 * j + 1] = tmp_vtx[2 * (j + 1) + 1];
|
||||
tmp_vtx[2 * (j + 1)] = tmp[0];
|
||||
tmp_vtx[2 * (j + 1) + 1] = tmp[1];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -475,21 +488,21 @@ _glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
|
|||
if (DEBUG_CLIP_VTX) {
|
||||
ErrorF("\nAfter sort vertex number is:\n");
|
||||
for (i = 0; i < vertex_num / 2; i++) {
|
||||
ErrorF("(%d, %d) ", tmp_vtx[2*i], tmp_vtx[2*i + 1]);
|
||||
ErrorF("(%d, %d) ", tmp_vtx[2 * i], tmp_vtx[2 * i + 1]);
|
||||
}
|
||||
ErrorF("\n");
|
||||
}
|
||||
|
||||
memset(vertex, -1, 2*6);
|
||||
memset(vertex, -1, 2 * 6);
|
||||
*num = 0;
|
||||
|
||||
for (i = 0; i < vertex_num / 2; i++) {
|
||||
if (*num > 0 && vertex[2*(*num - 1)] == tmp_vtx[2*i]
|
||||
&& vertex[2*(*num - 1) + 1] == tmp_vtx[2*i + 1]) {
|
||||
/*same vertex.*/
|
||||
if (*num > 0 && vertex[2 * (*num - 1)] == tmp_vtx[2 * i]
|
||||
&& vertex[2 * (*num - 1) + 1] == tmp_vtx[2 * i + 1]) {
|
||||
/*same vertex. */
|
||||
if (DEBUG_CLIP_VTX)
|
||||
ErrorF("X Point:(%d, %d) discard\n",
|
||||
tmp_vtx[2*i], tmp_vtx[2*i + 1]);
|
||||
tmp_vtx[2 * i], tmp_vtx[2 * i + 1]);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -506,28 +519,29 @@ _glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
|
|||
}
|
||||
}
|
||||
|
||||
vertex[2*(*num - 1)] = tmp_vtx[2*i];
|
||||
vertex[2*(*num - 1) + 1] = tmp_vtx[2*i + 1];
|
||||
vertex[2 * (*num - 1)] = tmp_vtx[2 * i];
|
||||
vertex[2 * (*num - 1) + 1] = tmp_vtx[2 * i + 1];
|
||||
if (DEBUG_CLIP_VTX)
|
||||
ErrorF("@ Point:(%d, %d) select, num now is %d\n",
|
||||
tmp_vtx[2*i], tmp_vtx[2*i + 1], *num);
|
||||
tmp_vtx[2 * i], tmp_vtx[2 * i + 1], *num);
|
||||
}
|
||||
|
||||
/* Now we need to arrange the vtx in the polygon's counter-clockwise
|
||||
order. We first select the left and top point as the start point and
|
||||
sort every vtx by the slope from vtx to the start vtx. */
|
||||
for (i = 1; i < *num; i++) {
|
||||
tmp_vtx_slope[i] = (vertex[2*i] != vertex[0] ?
|
||||
(float)(vertex[2*i + 1] - vertex[1]) / (float)(vertex[2*i] - vertex[0])
|
||||
: (float)INT_MAX);
|
||||
tmp_vtx_slope[i] = (vertex[2 * i] != vertex[0] ?
|
||||
(float) (vertex[2 * i + 1] -
|
||||
vertex[1]) / (float) (vertex[2 * i] -
|
||||
vertex[0])
|
||||
: (float) INT_MAX);
|
||||
}
|
||||
|
||||
if (DEBUG_CLIP_VTX) {
|
||||
ErrorF("\nvtx number: %d, VTX and slope:\n", *num);
|
||||
for (i = 0; i < *num; i++) {
|
||||
ErrorF("(%d, %d):%f ",
|
||||
vertex[2*i], vertex[2*i + 1],
|
||||
tmp_vtx_slope[i]);
|
||||
vertex[2 * i], vertex[2 * i + 1], tmp_vtx_slope[i]);
|
||||
}
|
||||
ErrorF("\n");
|
||||
}
|
||||
|
@ -536,17 +550,18 @@ _glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
|
|||
for (i = 0; i < *num - 1; i++) {
|
||||
int j;
|
||||
float tmp_slope;
|
||||
|
||||
for (j = 1; j < *num - i - 1; j++) {
|
||||
if (tmp_vtx_slope[j] < tmp_vtx_slope[j + 1]) {
|
||||
tmp_slope = tmp_vtx_slope[j];
|
||||
tmp_vtx_slope[j] = tmp_vtx_slope[j + 1];
|
||||
tmp_vtx_slope[j + 1] = tmp_slope;
|
||||
tmp[0] = vertex[2*j];
|
||||
tmp[1] = vertex[2*j + 1];
|
||||
vertex[2*j] = vertex[2*(j+1)];
|
||||
vertex[2*j + 1] = vertex[2*(j+1) + 1];
|
||||
vertex[2*(j+1)] = tmp[0];
|
||||
vertex[2*(j+1) + 1] = tmp[1];
|
||||
tmp[0] = vertex[2 * j];
|
||||
tmp[1] = vertex[2 * j + 1];
|
||||
vertex[2 * j] = vertex[2 * (j + 1)];
|
||||
vertex[2 * j + 1] = vertex[2 * (j + 1) + 1];
|
||||
vertex[2 * (j + 1)] = tmp[0];
|
||||
vertex[2 * (j + 1) + 1] = tmp[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -555,8 +570,7 @@ _glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
|
|||
ErrorF("\nBefore return, vtx number: %d, VTX and slope:\n", *num);
|
||||
for (i = 0; i < *num; i++) {
|
||||
ErrorF("(%d, %d):%f ",
|
||||
vertex[2*i], vertex[2*i + 1],
|
||||
tmp_vtx_slope[i]);
|
||||
vertex[2 * i], vertex[2 * i + 1], tmp_vtx_slope[i]);
|
||||
}
|
||||
ErrorF("\n");
|
||||
}
|
||||
|
@ -567,8 +581,7 @@ _glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
|
|||
static void
|
||||
glamor_setup_composite_vbo_for_trapezoid(ScreenPtr screen, int n_verts)
|
||||
{
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_gl_dispatch *dispatch;
|
||||
int stride;
|
||||
int vert_size;
|
||||
|
@ -607,18 +620,19 @@ glamor_setup_composite_vbo_for_trapezoid(ScreenPtr screen, int n_verts)
|
|||
glamor_priv->vb_stride;
|
||||
glamor_priv->vbo_offset = 0;
|
||||
dispatch->glBufferData(GL_ARRAY_BUFFER,
|
||||
glamor_priv->vbo_size,
|
||||
NULL, GL_STREAM_DRAW);
|
||||
glamor_priv->vbo_size, NULL, GL_STREAM_DRAW);
|
||||
}
|
||||
|
||||
glamor_priv->vb = dispatch->glMapBufferRange(GL_ARRAY_BUFFER,
|
||||
glamor_priv->vbo_offset,
|
||||
vert_size,
|
||||
GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
|
||||
GL_MAP_WRITE_BIT |
|
||||
GL_MAP_UNSYNCHRONIZED_BIT);
|
||||
|
||||
assert(glamor_priv->vb != NULL);
|
||||
glamor_priv->vb -= glamor_priv->vbo_offset;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
glamor_priv->vbo_offset = 0;
|
||||
}
|
||||
|
||||
|
@ -627,31 +641,35 @@ glamor_setup_composite_vbo_for_trapezoid(ScreenPtr screen, int n_verts)
|
|||
/* Set the vertex pointer. */
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, glamor_priv->vb_stride,
|
||||
(void *) ((long)glamor_priv->vbo_offset));
|
||||
(void *) ((long) glamor_priv->vbo_offset));
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
stride = 2;
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
|
||||
GL_FALSE, glamor_priv->vb_stride,
|
||||
(void *) ((long)glamor_priv->vbo_offset + stride * sizeof(float)));
|
||||
(void *) ((long) glamor_priv->vbo_offset +
|
||||
stride * sizeof(float)));
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
stride += 2;
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_TOP_BOTTOM, 2, GL_FLOAT,
|
||||
GL_FALSE, glamor_priv->vb_stride,
|
||||
(void *) ((long)glamor_priv->vbo_offset + stride * sizeof(float)));
|
||||
(void *) ((long) glamor_priv->vbo_offset +
|
||||
stride * sizeof(float)));
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_TOP_BOTTOM);
|
||||
stride += 2;
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_LEFT_PARAM, 4, GL_FLOAT,
|
||||
GL_FALSE, glamor_priv->vb_stride,
|
||||
(void *) ((long)glamor_priv->vbo_offset + stride * sizeof(float)));
|
||||
(void *) ((long) glamor_priv->vbo_offset +
|
||||
stride * sizeof(float)));
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_LEFT_PARAM);
|
||||
stride += 4;
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_RIGHT_PARAM, 4, GL_FLOAT,
|
||||
GL_FALSE, glamor_priv->vb_stride,
|
||||
(void *) ((long)glamor_priv->vbo_offset + stride * sizeof(float)));
|
||||
(void *) ((long) glamor_priv->vbo_offset +
|
||||
stride * sizeof(float)));
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_RIGHT_PARAM);
|
||||
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
|
@ -660,8 +678,8 @@ glamor_setup_composite_vbo_for_trapezoid(ScreenPtr screen, int n_verts)
|
|||
static Bool
|
||||
_glamor_trapezoids_with_shader(CARD8 op,
|
||||
PicturePtr src, PicturePtr dst,
|
||||
PictFormatPtr mask_format, INT16 x_src, INT16 y_src,
|
||||
int ntrap, xTrapezoid * traps)
|
||||
PictFormatPtr mask_format, INT16 x_src,
|
||||
INT16 y_src, int ntrap, xTrapezoid * traps)
|
||||
{
|
||||
ScreenPtr screen = dst->pDrawable->pScreen;
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
|
@ -689,13 +707,13 @@ _glamor_trapezoids_with_shader(CARD8 op,
|
|||
int nclip_rect;
|
||||
int mclip_rect;
|
||||
int clip_processed;
|
||||
int clipped_vtx[6*2];
|
||||
int clipped_vtx[6 * 2];
|
||||
RegionRec region;
|
||||
BoxPtr box = NULL;
|
||||
BoxPtr pbox = NULL;
|
||||
int traps_count = 0;
|
||||
int traps_not_completed = 0;
|
||||
xTrapezoid * ptrap = NULL;
|
||||
xTrapezoid *ptrap = NULL;
|
||||
int nbox;
|
||||
float src_matrix[9];
|
||||
Bool ret = FALSE;
|
||||
|
@ -728,7 +746,7 @@ _glamor_trapezoids_with_shader(CARD8 op,
|
|||
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dest_pixmap_priv)
|
||||
|| dest_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
/* Currently. Always fallback to cpu if destination is in CPU memory.*/
|
||||
/* Currently. Always fallback to cpu if destination is in CPU memory. */
|
||||
ret = FALSE;
|
||||
DEBUGF("dst pixmap has no FBO.\n");
|
||||
goto TRAPEZOID_OUT;
|
||||
|
@ -755,13 +773,13 @@ _glamor_trapezoids_with_shader(CARD8 op,
|
|||
x_temp_src = x_src + bounds.x1 - (traps[0].left.p1.x >> 16);
|
||||
y_temp_src = y_src + bounds.y1 - (traps[0].left.p1.y >> 16);
|
||||
|
||||
if ((!src->pDrawable &&
|
||||
(src->pSourcePict->type != SourcePictTypeSolidFill)) //1. The Gradient case.
|
||||
/* 2. Has no fbo but can upload.*/
|
||||
if ((!src->pDrawable && (src->pSourcePict->type != SourcePictTypeSolidFill)) //1. The Gradient case.
|
||||
/* 2. Has no fbo but can upload. */
|
||||
|| (src->pDrawable && !GLAMOR_PIXMAP_PRIV_HAS_FBO(source_pixmap_priv)
|
||||
&& ((src_width * src_height * 4 <
|
||||
source_pixmap->drawable.width * source_pixmap->drawable.height)
|
||||
|| !glamor_check_fbo_size(glamor_priv, source_pixmap->drawable.width,
|
||||
|| !glamor_check_fbo_size(glamor_priv,
|
||||
source_pixmap->drawable.width,
|
||||
source_pixmap->drawable.height)))) {
|
||||
|
||||
if (!glamor_check_fbo_size(glamor_priv, src_width, src_height)) {
|
||||
|
@ -777,7 +795,8 @@ _glamor_trapezoids_with_shader(CARD8 op,
|
|||
DEBUGF("Convert gradient picture failed\n");
|
||||
goto TRAPEZOID_OUT;
|
||||
}
|
||||
temp_src_priv = glamor_get_pixmap_private((PixmapPtr)temp_src->pDrawable);
|
||||
temp_src_priv =
|
||||
glamor_get_pixmap_private((PixmapPtr) temp_src->pDrawable);
|
||||
x_temp_src = y_temp_src = 0;
|
||||
}
|
||||
|
||||
|
@ -791,9 +810,7 @@ _glamor_trapezoids_with_shader(CARD8 op,
|
|||
if (!miComputeCompositeRegion(®ion,
|
||||
temp_src, NULL, dst,
|
||||
x_temp_src, y_temp_src,
|
||||
0, 0,
|
||||
x_dst, y_dst,
|
||||
src_width, src_height)) {
|
||||
0, 0, x_dst, y_dst, src_width, src_height)) {
|
||||
DEBUGF("All the regions are clipped out, do nothing\n");
|
||||
goto TRAPEZOID_OUT;
|
||||
}
|
||||
|
@ -804,7 +821,8 @@ _glamor_trapezoids_with_shader(CARD8 op,
|
|||
|
||||
ret = glamor_composite_choose_shader(op, temp_src, NULL, dst,
|
||||
temp_src_priv, NULL, dest_pixmap_priv,
|
||||
&key, &shader, &op_info, &saved_source_format);
|
||||
&key, &shader, &op_info,
|
||||
&saved_source_format);
|
||||
if (ret == FALSE) {
|
||||
DEBUGF("can not set the shader program for composite\n");
|
||||
goto TRAPEZOID_RESET_GL;
|
||||
|
@ -826,10 +844,8 @@ _glamor_trapezoids_with_shader(CARD8 op,
|
|||
source_pixmap = glamor_get_drawable_pixmap(temp_src->pDrawable);
|
||||
source_pixmap_priv = glamor_get_pixmap_private(source_pixmap);
|
||||
glamor_get_drawable_deltas(temp_src->pDrawable,
|
||||
source_pixmap,
|
||||
&source_x_off, &source_y_off);
|
||||
pixmap_priv_get_scale(source_pixmap_priv,
|
||||
&src_xscale, &src_yscale);
|
||||
source_pixmap, &source_x_off, &source_y_off);
|
||||
pixmap_priv_get_scale(source_pixmap_priv, &src_xscale, &src_yscale);
|
||||
glamor_picture_get_matrixf(temp_src, src_matrix);
|
||||
vert_stride += 3;
|
||||
}
|
||||
|
@ -842,8 +858,10 @@ _glamor_trapezoids_with_shader(CARD8 op,
|
|||
|
||||
/* A trapezoid clip with a rectangle will at most generate a hexagon,
|
||||
which can be devided into 4 triangles to render. */
|
||||
ntriangle_per_loop = (vert_stride * nbox * ntrap * 4) > GLAMOR_COMPOSITE_VBO_VERT_CNT ?
|
||||
(GLAMOR_COMPOSITE_VBO_VERT_CNT / vert_stride) : nbox * ntrap * 4;
|
||||
ntriangle_per_loop =
|
||||
(vert_stride * nbox * ntrap * 4) >
|
||||
GLAMOR_COMPOSITE_VBO_VERT_CNT ? (GLAMOR_COMPOSITE_VBO_VERT_CNT /
|
||||
vert_stride) : nbox * ntrap * 4;
|
||||
ntriangle_per_loop = (ntriangle_per_loop / 4) * 4;
|
||||
|
||||
nclip_rect = nbox;
|
||||
|
@ -851,64 +869,69 @@ _glamor_trapezoids_with_shader(CARD8 op,
|
|||
mclip_rect = (nclip_rect * ntrap * 4) > ntriangle_per_loop ?
|
||||
(ntriangle_per_loop / (4 * ntrap)) : nclip_rect;
|
||||
|
||||
if (!mclip_rect) {/* Maybe too many traps. */
|
||||
if (!mclip_rect) { /* Maybe too many traps. */
|
||||
mclip_rect = 1;
|
||||
ptrap = traps;
|
||||
traps_count = ntriangle_per_loop / 4;
|
||||
traps_not_completed = ntrap - traps_count;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
traps_count = ntrap;
|
||||
ptrap = traps;
|
||||
traps_not_completed = 0;
|
||||
}
|
||||
|
||||
NTRAPS_LOOP_AGAIN:
|
||||
NTRAPS_LOOP_AGAIN:
|
||||
|
||||
glamor_setup_composite_vbo(screen, mclip_rect * traps_count * 4 * vert_stride);
|
||||
glamor_setup_composite_vbo(screen,
|
||||
mclip_rect * traps_count * 4 * vert_stride);
|
||||
clip_processed = mclip_rect;
|
||||
|
||||
|
||||
while (mclip_rect--) {
|
||||
while (traps_count--) {
|
||||
int vtx_num;
|
||||
int i;
|
||||
float vertices[3*2], source_texcoords[3*2];
|
||||
float vertices[3 * 2], source_texcoords[3 * 2];
|
||||
|
||||
DEBUGF("In loop of render trapezoid, nclip_rect = %d, mclip_rect = %d, "
|
||||
DEBUGF
|
||||
("In loop of render trapezoid, nclip_rect = %d, mclip_rect = %d, "
|
||||
"clip_processed = %d, traps_count = %d, traps_not_completed = %d\n",
|
||||
nclip_rect, mclip_rect, clip_processed, traps_count, traps_not_completed);
|
||||
nclip_rect, mclip_rect, clip_processed, traps_count,
|
||||
traps_not_completed);
|
||||
|
||||
if (_glamor_clip_trapezoid_vertex(ptrap, pbox, clipped_vtx, &vtx_num)) {
|
||||
if (_glamor_clip_trapezoid_vertex
|
||||
(ptrap, pbox, clipped_vtx, &vtx_num)) {
|
||||
for (i = 0; i < vtx_num - 2; i++) {
|
||||
int clipped_vtx_tmp[3*2];
|
||||
int clipped_vtx_tmp[3 * 2];
|
||||
|
||||
clipped_vtx_tmp[0] = clipped_vtx[0];
|
||||
clipped_vtx_tmp[1] = clipped_vtx[1];
|
||||
clipped_vtx_tmp[2] = clipped_vtx[(i+1)*2];
|
||||
clipped_vtx_tmp[3] = clipped_vtx[(i+1)*2 + 1];
|
||||
clipped_vtx_tmp[4] = clipped_vtx[(i+2)*2];
|
||||
clipped_vtx_tmp[5] = clipped_vtx[(i+2)*2 + 1];
|
||||
glamor_set_normalize_tri_vcoords(
|
||||
dst_xscale, dst_yscale, clipped_vtx_tmp,
|
||||
glamor_priv->yInverted, vertices);
|
||||
clipped_vtx_tmp[2] = clipped_vtx[(i + 1) * 2];
|
||||
clipped_vtx_tmp[3] = clipped_vtx[(i + 1) * 2 + 1];
|
||||
clipped_vtx_tmp[4] = clipped_vtx[(i + 2) * 2];
|
||||
clipped_vtx_tmp[5] = clipped_vtx[(i + 2) * 2 + 1];
|
||||
glamor_set_normalize_tri_vcoords(dst_xscale, dst_yscale,
|
||||
clipped_vtx_tmp,
|
||||
glamor_priv->yInverted,
|
||||
vertices);
|
||||
DEBUGF("vertices of triangle: (%f X %f), (%f X %f), "
|
||||
"(%f X %f)\n", vertices[0], vertices[1],
|
||||
vertices[2], vertices[3], vertices[4], vertices[5]);
|
||||
|
||||
vertices[2], vertices[3], vertices[4],
|
||||
vertices[5]);
|
||||
|
||||
if (key.source != SHADER_SOURCE_SOLID) {
|
||||
if (src->transform) {
|
||||
glamor_set_transformed_normalize_tri_tcoords(
|
||||
source_pixmap_priv,
|
||||
src_matrix, src_xscale, src_yscale,
|
||||
glamor_set_transformed_normalize_tri_tcoords
|
||||
(source_pixmap_priv, src_matrix, src_xscale,
|
||||
src_yscale, clipped_vtx_tmp,
|
||||
glamor_priv->yInverted, source_texcoords);
|
||||
}
|
||||
else {
|
||||
glamor_set_normalize_tri_tcoords(src_xscale,
|
||||
src_yscale,
|
||||
clipped_vtx_tmp,
|
||||
glamor_priv->yInverted,
|
||||
source_texcoords);
|
||||
} else {
|
||||
glamor_set_normalize_tri_tcoords(
|
||||
src_xscale, src_yscale,
|
||||
clipped_vtx_tmp,
|
||||
glamor_priv->yInverted,
|
||||
glamor_priv->
|
||||
yInverted,
|
||||
source_texcoords);
|
||||
}
|
||||
|
||||
|
@ -934,7 +957,8 @@ NTRAPS_LOOP_AGAIN:
|
|||
traps_not_completed -= traps_count;
|
||||
glamor_flush_composite_triangles(screen);
|
||||
goto NTRAPS_LOOP_AGAIN;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ptrap = traps;
|
||||
traps_count = ntrap;
|
||||
}
|
||||
|
@ -949,7 +973,7 @@ NTRAPS_LOOP_AGAIN:
|
|||
|
||||
ret = TRUE;
|
||||
|
||||
TRAPEZOID_RESET_GL:
|
||||
TRAPEZOID_RESET_GL:
|
||||
dispatch->glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
|
@ -964,14 +988,15 @@ TRAPEZOID_RESET_GL:
|
|||
#endif
|
||||
dispatch->glUseProgram(0);
|
||||
|
||||
TRAPEZOID_OUT:
|
||||
TRAPEZOID_OUT:
|
||||
if (box) {
|
||||
REGION_UNINIT(dst->pDrawable->pScreen, ®ion);
|
||||
}
|
||||
|
||||
if (temp_src != src) {
|
||||
FreePicture(temp_src, 0);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (saved_source_format) {
|
||||
src->format = saved_source_format;
|
||||
}
|
||||
|
@ -1363,7 +1388,8 @@ glamor_fini_trapezoid_shader(ScreenPtr screen)
|
|||
|
||||
static Bool
|
||||
_glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
|
||||
xTrapezoid * traps, int ntrap, BoxRec *bounds)
|
||||
xTrapezoid *traps, int ntrap,
|
||||
BoxRec *bounds)
|
||||
{
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
|
@ -1427,7 +1453,8 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
|
|||
for (j = 0; j < mrect; j++) {
|
||||
ptrap = traps + i + j;
|
||||
|
||||
DEBUGF("--- The parameter of xTrapezoid is:\ntop: %d 0x%x\tbottom: %d 0x%x\n"
|
||||
DEBUGF
|
||||
("--- The parameter of xTrapezoid is:\ntop: %d 0x%x\tbottom: %d 0x%x\n"
|
||||
"left: p1 (%d 0x%x, %d 0x%x)\tp2 (%d 0x%x, %d 0x%x)\n"
|
||||
"right: p1 (%d 0x%x, %d 0x%x)\tp2 (%d 0x%x, %d 0x%x)\n",
|
||||
xFixedToInt(ptrap->top), ptrap->top,
|
||||
|
@ -1443,20 +1470,18 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
|
|||
|
||||
miTrapezoidBounds(1, ptrap, &one_trap_bound);
|
||||
|
||||
vertices = (float*)(glamor_priv->vb + glamor_priv->vbo_offset) + 2;
|
||||
vertices =
|
||||
(float *) (glamor_priv->vb + glamor_priv->vbo_offset) + 2;
|
||||
glamor_set_tcoords_ext((pixmap_priv->base.pixmap->drawable.width),
|
||||
(pixmap_priv->base.pixmap->drawable.height),
|
||||
(one_trap_bound.x1),
|
||||
(one_trap_bound.y1),
|
||||
(one_trap_bound.x2),
|
||||
(one_trap_bound.y2),
|
||||
(one_trap_bound.x1), (one_trap_bound.y1),
|
||||
(one_trap_bound.x2), (one_trap_bound.y2),
|
||||
glamor_priv->yInverted, vertices, stride);
|
||||
DEBUGF("tex_vertices --> leftup : %f X %f, rightup: %f X %f,"
|
||||
"rightbottom: %f X %f, leftbottom : %f X %f\n",
|
||||
vertices[0], vertices[1],
|
||||
vertices[1*stride], vertices[1*stride + 1],
|
||||
vertices[2*stride], vertices[2*stride + 1],
|
||||
vertices[3*stride], vertices[3*stride + 1]);
|
||||
"rightbottom: %f X %f, leftbottom : %f X %f\n", vertices[0],
|
||||
vertices[1], vertices[1 * stride], vertices[1 * stride + 1],
|
||||
vertices[2 * stride], vertices[2 * stride + 1],
|
||||
vertices[3 * stride], vertices[3 * stride + 1]);
|
||||
|
||||
/* Need to rebase. */
|
||||
one_trap_bound.x1 -= bounds->x1;
|
||||
|
@ -1467,33 +1492,36 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
|
|||
vertices -= 2;
|
||||
|
||||
glamor_set_normalize_vcoords_ext(pixmap_priv, xscale, yscale,
|
||||
one_trap_bound.x1, one_trap_bound.y1,
|
||||
one_trap_bound.x2, one_trap_bound.y2,
|
||||
glamor_priv->yInverted, vertices, stride);
|
||||
one_trap_bound.x1,
|
||||
one_trap_bound.y1,
|
||||
one_trap_bound.x2,
|
||||
one_trap_bound.y2,
|
||||
glamor_priv->yInverted, vertices,
|
||||
stride);
|
||||
DEBUGF("vertices --> leftup : %f X %f, rightup: %f X %f,"
|
||||
"rightbottom: %f X %f, leftbottom : %f X %f\n",
|
||||
vertices[0], vertices[1],
|
||||
vertices[1*stride], vertices[1*stride + 1],
|
||||
vertices[2*stride], vertices[2*stride + 1],
|
||||
vertices[3*stride], vertices[3*stride + 1]);
|
||||
"rightbottom: %f X %f, leftbottom : %f X %f\n", vertices[0],
|
||||
vertices[1], vertices[1 * stride], vertices[1 * stride + 1],
|
||||
vertices[2 * stride], vertices[2 * stride + 1],
|
||||
vertices[3 * stride], vertices[3 * stride + 1]);
|
||||
vertices += 4;
|
||||
|
||||
/* Set the top and bottom. */
|
||||
params[0] = ((float)ptrap->top) / 65536;
|
||||
params[1] = ((float)ptrap->bottom) / 65536;
|
||||
params[0] = ((float) ptrap->top) / 65536;
|
||||
params[1] = ((float) ptrap->bottom) / 65536;
|
||||
glamor_set_const_ext(params, 2, vertices, 4, stride);
|
||||
vertices += 2;
|
||||
|
||||
/* Set the left params. */
|
||||
params[0] = ((float)ptrap->left.p1.x) / 65536;
|
||||
params[1] = ((float)ptrap->left.p1.y) / 65536;
|
||||
params[0] = ((float) ptrap->left.p1.x) / 65536;
|
||||
params[1] = ((float) ptrap->left.p1.y) / 65536;
|
||||
|
||||
if (ptrap->left.p1.x == ptrap->left.p2.x) {
|
||||
left_slope = 0.0;
|
||||
params[3] = 1.0;
|
||||
} else {
|
||||
left_slope = ((float)(ptrap->left.p1.y - ptrap->left.p2.y))
|
||||
/ ((float)(ptrap->left.p1.x - ptrap->left.p2.x));
|
||||
}
|
||||
else {
|
||||
left_slope = ((float) (ptrap->left.p1.y - ptrap->left.p2.y))
|
||||
/ ((float) (ptrap->left.p1.x - ptrap->left.p2.x));
|
||||
params[3] = 0.0;
|
||||
}
|
||||
params[2] = left_slope;
|
||||
|
@ -1501,15 +1529,16 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
|
|||
vertices += 4;
|
||||
|
||||
/* Set the left params. */
|
||||
params[0] = ((float)ptrap->right.p1.x) / 65536;
|
||||
params[1] = ((float)ptrap->right.p1.y) / 65536;
|
||||
params[0] = ((float) ptrap->right.p1.x) / 65536;
|
||||
params[1] = ((float) ptrap->right.p1.y) / 65536;
|
||||
|
||||
if (ptrap->right.p1.x == ptrap->right.p2.x) {
|
||||
right_slope = 0.0;
|
||||
params[3] = 1.0;
|
||||
} else {
|
||||
right_slope = ((float)(ptrap->right.p1.y - ptrap->right.p2.y))
|
||||
/ ((float)(ptrap->right.p1.x - ptrap->right.p2.x));
|
||||
}
|
||||
else {
|
||||
right_slope = ((float) (ptrap->right.p1.y - ptrap->right.p2.y))
|
||||
/ ((float) (ptrap->right.p1.x - ptrap->right.p2.x));
|
||||
params[3] = 0.0;
|
||||
}
|
||||
params[2] = right_slope;
|
||||
|
@ -1518,11 +1547,12 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
|
|||
DEBUGF("trap_top = %f, trap_bottom = %f, "
|
||||
"trap_left_x = %f, trap_left_y = %f, left_slope = %f, "
|
||||
"trap_right_x = %f, trap_right_y = %f, right_slope = %f\n",
|
||||
((float)ptrap->top) / 65536, ((float)ptrap->bottom) / 65536,
|
||||
((float)ptrap->left.p1.x) / 65536, ((float)ptrap->left.p1.y) / 65536,
|
||||
left_slope,
|
||||
((float)ptrap->right.p1.x) / 65536, ((float)ptrap->right.p1.y) / 65536,
|
||||
right_slope);
|
||||
((float) ptrap->top) / 65536,
|
||||
((float) ptrap->bottom) / 65536,
|
||||
((float) ptrap->left.p1.x) / 65536,
|
||||
((float) ptrap->left.p1.y) / 65536, left_slope,
|
||||
((float) ptrap->right.p1.x) / 65536,
|
||||
((float) ptrap->right.p1.y) / 65536, right_slope);
|
||||
|
||||
glamor_priv->render_nr_verts += 4;
|
||||
glamor_priv->vbo_offset += glamor_priv->vb_stride * 4;
|
||||
|
@ -1544,11 +1574,13 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
|
|||
}
|
||||
|
||||
#ifndef GLAMOR_GLES2
|
||||
dispatch->glDrawRangeElements(GL_TRIANGLES, 0, glamor_priv->render_nr_verts,
|
||||
dispatch->glDrawRangeElements(GL_TRIANGLES, 0,
|
||||
glamor_priv->render_nr_verts,
|
||||
(glamor_priv->render_nr_verts * 3) / 2,
|
||||
GL_UNSIGNED_SHORT, NULL);
|
||||
#else
|
||||
dispatch->glDrawElements(GL_TRIANGLES, (glamor_priv->render_nr_verts * 3) / 2,
|
||||
dispatch->glDrawElements(GL_TRIANGLES,
|
||||
(glamor_priv->render_nr_verts * 3) / 2,
|
||||
GL_UNSIGNED_SHORT, NULL);
|
||||
#endif
|
||||
}
|
||||
|
@ -1584,11 +1616,9 @@ glamor_create_mask_picture(ScreenPtr screen,
|
|||
|
||||
if (!pict_format) {
|
||||
if (dst->polyEdge == PolyEdgeSharp)
|
||||
pict_format =
|
||||
PictureMatchFormat(screen, 1, PICT_a1);
|
||||
pict_format = PictureMatchFormat(screen, 1, PICT_a1);
|
||||
else
|
||||
pict_format =
|
||||
PictureMatchFormat(screen, 8, PICT_a8);
|
||||
pict_format = PictureMatchFormat(screen, 8, PICT_a8);
|
||||
if (!pict_format)
|
||||
return 0;
|
||||
}
|
||||
|
@ -1596,7 +1626,8 @@ glamor_create_mask_picture(ScreenPtr screen,
|
|||
if (gpu) {
|
||||
pixmap = glamor_create_pixmap(screen, width, height,
|
||||
pict_format->depth, 0);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pixmap = glamor_create_pixmap(screen, 0, 0,
|
||||
pict_format->depth,
|
||||
GLAMOR_CREATE_PIXMAP_CPU);
|
||||
|
@ -1611,9 +1642,10 @@ glamor_create_mask_picture(ScreenPtr screen,
|
|||
}
|
||||
|
||||
static int
|
||||
_glamor_trapezoid_bounds (int ntrap, xTrapezoid *traps, BoxPtr box)
|
||||
_glamor_trapezoid_bounds(int ntrap, xTrapezoid *traps, BoxPtr box)
|
||||
{
|
||||
int has_large_trapezoid = 0;
|
||||
|
||||
box->y1 = MAXSHORT;
|
||||
box->y2 = MINSHORT;
|
||||
box->x1 = MAXSHORT;
|
||||
|
@ -1624,21 +1656,26 @@ _glamor_trapezoid_bounds (int ntrap, xTrapezoid *traps, BoxPtr box)
|
|||
|
||||
if (!xTrapezoidValid(traps))
|
||||
continue;
|
||||
y1 = xFixedToInt (traps->top);
|
||||
y1 = xFixedToInt(traps->top);
|
||||
if (y1 < box->y1)
|
||||
box->y1 = y1;
|
||||
|
||||
y2 = xFixedToInt (xFixedCeil (traps->bottom));
|
||||
y2 = xFixedToInt(xFixedCeil(traps->bottom));
|
||||
if (y2 > box->y2)
|
||||
box->y2 = y2;
|
||||
|
||||
x1 = xFixedToInt (min (_glamor_linefixedX (&traps->left, traps->top, FALSE),
|
||||
_glamor_linefixedX (&traps->left, traps->bottom, FALSE)));
|
||||
x1 = xFixedToInt(min
|
||||
(_glamor_linefixedX(&traps->left, traps->top, FALSE),
|
||||
_glamor_linefixedX(&traps->left, traps->bottom,
|
||||
FALSE)));
|
||||
if (x1 < box->x1)
|
||||
box->x1 = x1;
|
||||
|
||||
x2 = xFixedToInt (xFixedCeil (max (_glamor_linefixedX (&traps->right, traps->top, TRUE),
|
||||
_glamor_linefixedX (&traps->right, traps->bottom, TRUE))));
|
||||
x2 = xFixedToInt(xFixedCeil
|
||||
(max
|
||||
(_glamor_linefixedX(&traps->right, traps->top, TRUE),
|
||||
_glamor_linefixedX(&traps->right, traps->bottom,
|
||||
TRUE))));
|
||||
if (x2 > box->x2)
|
||||
box->x2 = x2;
|
||||
|
||||
|
@ -1658,7 +1695,7 @@ static Bool
|
|||
_glamor_trapezoids(CARD8 op,
|
||||
PicturePtr src, PicturePtr dst,
|
||||
PictFormatPtr mask_format, INT16 x_src, INT16 y_src,
|
||||
int ntrap, xTrapezoid * traps, Bool fallback)
|
||||
int ntrap, xTrapezoid *traps, Bool fallback)
|
||||
{
|
||||
ScreenPtr screen = dst->pDrawable->pScreen;
|
||||
BoxRec bounds;
|
||||
|
@ -1676,11 +1713,9 @@ _glamor_trapezoids(CARD8 op,
|
|||
*/
|
||||
if (!mask_format) {
|
||||
if (dst->polyEdge == PolyEdgeSharp)
|
||||
mask_format =
|
||||
PictureMatchFormat(screen, 1, PICT_a1);
|
||||
mask_format = PictureMatchFormat(screen, 1, PICT_a1);
|
||||
else
|
||||
mask_format =
|
||||
PictureMatchFormat(screen, 8, PICT_a8);
|
||||
mask_format = PictureMatchFormat(screen, 8, PICT_a8);
|
||||
for (; ntrap; ntrap--, traps++)
|
||||
glamor_trapezoids(op, src, dst, mask_format, x_src,
|
||||
y_src, 1, traps);
|
||||
|
@ -1718,14 +1753,16 @@ _glamor_trapezoids(CARD8 op,
|
|||
if (mask_format->depth == 1) {
|
||||
ret = _glamor_trapezoids_with_shader(op, src, dst, mask_format,
|
||||
x_src, y_src, ntrap, traps);
|
||||
if(ret)
|
||||
if (ret)
|
||||
return TRUE;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (has_large_trapezoid || ntrap > 256) {
|
||||
/* The shader speed is relative slower than pixman when generating big chunk
|
||||
trapezoid mask. We fallback to pixman to improve the performance. */
|
||||
;
|
||||
} else if (dst->polyMode == PolyModeImprecise) {
|
||||
}
|
||||
else if (dst->polyMode == PolyModeImprecise) {
|
||||
/* The precise mode is that we sample the trapezoid on the centre points of
|
||||
an (2*n+1)x(2*n-1) subpixel grid. It is computationally expensive in shader
|
||||
and we use inside area ratio to replace it if the polymode == Imprecise. */
|
||||
|
@ -1734,7 +1771,9 @@ _glamor_trapezoids(CARD8 op,
|
|||
if (!picture)
|
||||
return TRUE;
|
||||
|
||||
ret = _glamor_generate_trapezoid_with_shader(screen, picture, traps, ntrap, &bounds);
|
||||
ret =
|
||||
_glamor_generate_trapezoid_with_shader(screen, picture, traps,
|
||||
ntrap, &bounds);
|
||||
|
||||
if (!ret)
|
||||
FreePicture(picture, 0);
|
||||
|
@ -1795,7 +1834,7 @@ void
|
|||
glamor_trapezoids(CARD8 op,
|
||||
PicturePtr src, PicturePtr dst,
|
||||
PictFormatPtr mask_format, INT16 x_src, INT16 y_src,
|
||||
int ntrap, xTrapezoid * traps)
|
||||
int ntrap, xTrapezoid *traps)
|
||||
{
|
||||
DEBUGF("x_src = %d, y_src = %d, ntrap = %d\n", x_src, y_src, ntrap);
|
||||
|
||||
|
@ -1807,7 +1846,7 @@ Bool
|
|||
glamor_trapezoids_nf(CARD8 op,
|
||||
PicturePtr src, PicturePtr dst,
|
||||
PictFormatPtr mask_format, INT16 x_src, INT16 y_src,
|
||||
int ntrap, xTrapezoid * traps)
|
||||
int ntrap, xTrapezoid *traps)
|
||||
{
|
||||
DEBUGF("x_src = %d, y_src = %d, ntrap = %d\n", x_src, y_src, ntrap);
|
||||
|
||||
|
@ -1816,4 +1855,3 @@ glamor_trapezoids_nf(CARD8 op,
|
|||
}
|
||||
|
||||
#endif /* RENDER */
|
||||
|
||||
|
|
|
@ -33,20 +33,18 @@ _glamor_triangles(CARD8 op,
|
|||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris, Bool fallback)
|
||||
INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris,
|
||||
Bool fallback)
|
||||
{
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(pDst->pDrawable)
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(pDst->pDrawable)
|
||||
&& (!pSrc->pDrawable
|
||||
|| glamor_ddx_fallback_check_pixmap(pSrc->pDrawable)))
|
||||
return FALSE;
|
||||
|
||||
if (glamor_prepare_access_picture(pDst, GLAMOR_ACCESS_RW)) {
|
||||
if (glamor_prepare_access_picture(pSrc,
|
||||
GLAMOR_ACCESS_RO)) {
|
||||
if (glamor_prepare_access_picture(pSrc, GLAMOR_ACCESS_RO)) {
|
||||
|
||||
fbTriangles(op, pSrc, pDst, maskFormat, xSrc,
|
||||
ySrc, ntris, tris);
|
||||
fbTriangles(op, pSrc, pDst, maskFormat, xSrc, ySrc, ntris, tris);
|
||||
|
||||
glamor_finish_access_picture(pSrc, GLAMOR_ACCESS_RO);
|
||||
}
|
||||
|
@ -77,4 +75,3 @@ glamor_triangles_nf(CARD8 op,
|
|||
return _glamor_triangles(op, pSrc, pDst, maskFormat,
|
||||
xSrc, ySrc, ntris, tris, FALSE);
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
|
||||
#define PIXMAP_PRIV_GET_ACTUAL_SIZE(priv, w, h) \
|
||||
do { \
|
||||
if (unlikely(priv->type == GLAMOR_TEXTURE_LARGE)) { \
|
||||
if (_X_UNLIKELY(priv->type == GLAMOR_TEXTURE_LARGE)) { \
|
||||
w = priv->large.box.x2 - priv->large.box.x1; \
|
||||
h = priv->large.box.y2 - priv->large.box.y1; \
|
||||
} else { \
|
||||
|
@ -80,7 +80,7 @@
|
|||
|
||||
#define pixmap_priv_get_fbo_off(_priv_, _xoff_, _yoff_) \
|
||||
do { \
|
||||
if (unlikely(_priv_ && (_priv_)->type == GLAMOR_TEXTURE_LARGE)) { \
|
||||
if (_X_UNLIKELY(_priv_ && (_priv_)->type == GLAMOR_TEXTURE_LARGE)) { \
|
||||
*(_xoff_) = - (_priv_)->large.box.x1; \
|
||||
*(_yoff_) = - (_priv_)->large.box.y1; \
|
||||
} else { \
|
||||
|
@ -254,7 +254,6 @@
|
|||
} \
|
||||
} while(0)
|
||||
|
||||
|
||||
/* _x1_ ... _y2_ may has fractional. */
|
||||
#define glamor_get_repeat_transform_coords(priv, repeat_type, tx1, \
|
||||
ty1, _x1_, _y1_) \
|
||||
|
@ -315,7 +314,7 @@
|
|||
texcoord, yInverted) \
|
||||
do { \
|
||||
(texcoord)[0] = t_from_x_coord_x(xscale, _tx_); \
|
||||
if (likely(yInverted)) \
|
||||
if (_X_LIKELY(yInverted)) \
|
||||
(texcoord)[1] = t_from_x_coord_y_inverted(yscale, _ty_);\
|
||||
else \
|
||||
(texcoord)[1] = t_from_x_coord_y(yscale, _ty_); \
|
||||
|
@ -338,7 +337,7 @@
|
|||
tx += fbo_x_off; \
|
||||
ty += fbo_y_off; \
|
||||
(texcoord)[0] = t_from_x_coord_x(xscale, tx); \
|
||||
if (likely(yInverted)) \
|
||||
if (_X_LIKELY(yInverted)) \
|
||||
(texcoord)[1] = t_from_x_coord_y_inverted(yscale, ty); \
|
||||
else \
|
||||
(texcoord)[1] = t_from_x_coord_y(yscale, ty); \
|
||||
|
@ -402,8 +401,6 @@
|
|||
2); \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
||||
#define glamor_set_normalize_tri_tcoords(xscale, \
|
||||
yscale, \
|
||||
vtx, \
|
||||
|
@ -435,7 +432,7 @@
|
|||
texcoords, \
|
||||
stride) \
|
||||
do { \
|
||||
if (likely(priv->type != GLAMOR_TEXTURE_LARGE)) { \
|
||||
if (_X_LIKELY(priv->type != GLAMOR_TEXTURE_LARGE)) { \
|
||||
glamor_set_transformed_normalize_tcoords_ext(priv, matrix, xscale, \
|
||||
yscale, _x1_, _y1_, \
|
||||
_x2_, _y2_, yInverted, \
|
||||
|
@ -475,7 +472,6 @@
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define glamor_set_repeat_transformed_normalize_tcoords( priv, \
|
||||
repeat_type, \
|
||||
matrix, \
|
||||
|
@ -509,7 +505,7 @@
|
|||
(vertices)[1 * stride] = _t2_ = t_from_x_coord_x(xscale, tx2); \
|
||||
(vertices)[2 * stride] = _t2_; \
|
||||
(vertices)[3 * stride] = _t0_; \
|
||||
if (likely(yInverted)) { \
|
||||
if (_X_LIKELY(yInverted)) { \
|
||||
(vertices)[1] = _t1_ = t_from_x_coord_y_inverted(yscale, ty1); \
|
||||
(vertices)[2 * stride + 1] = _t5_ = t_from_x_coord_y_inverted(yscale, ty2);\
|
||||
} \
|
||||
|
@ -525,7 +521,7 @@
|
|||
x1, y1, x2, y2, \
|
||||
yInverted, vertices, stride) \
|
||||
do { \
|
||||
if (unlikely(priv->type == GLAMOR_TEXTURE_LARGE)) { \
|
||||
if (_X_UNLIKELY(priv->type == GLAMOR_TEXTURE_LARGE)) { \
|
||||
float tx1, tx2, ty1, ty2; \
|
||||
int fbo_x_off, fbo_y_off; \
|
||||
pixmap_priv_get_fbo_off(priv, &fbo_x_off, &fbo_y_off); \
|
||||
|
@ -541,7 +537,6 @@
|
|||
x2, y2, yInverted, vertices, stride);\
|
||||
} while(0)
|
||||
|
||||
|
||||
#define glamor_set_normalize_tcoords(priv, xscale, yscale, \
|
||||
x1, y1, x2, y2, \
|
||||
yInverted, vertices) \
|
||||
|
@ -556,7 +551,7 @@
|
|||
_x1_, _y1_, _x2_, _y2_, \
|
||||
yInverted, vertices, stride)\
|
||||
do { \
|
||||
if (unlikely(priv->type == GLAMOR_TEXTURE_LARGE)) { \
|
||||
if (_X_UNLIKELY(priv->type == GLAMOR_TEXTURE_LARGE)) { \
|
||||
float tx1, tx2, ty1, ty2; \
|
||||
if (repeat_type == RepeatPad) { \
|
||||
tx1 = _x1_ - priv->large.box.x1; \
|
||||
|
@ -577,7 +572,6 @@
|
|||
stride); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define glamor_set_repeat_normalize_tcoords(priv, repeat_type, \
|
||||
xscale, yscale, \
|
||||
_x1_, _y1_, _x2_, _y2_, \
|
||||
|
@ -597,7 +591,7 @@
|
|||
(vertices)[2] = t_from_x_coord_x(xscale, x2); \
|
||||
(vertices)[6] = (vertices)[2]; \
|
||||
(vertices)[4] = (vertices)[0]; \
|
||||
if (likely(yInverted)) { \
|
||||
if (_X_LIKELY(yInverted)) { \
|
||||
(vertices)[1] = t_from_x_coord_y_inverted(yscale, y1); \
|
||||
(vertices)[7] = t_from_x_coord_y_inverted(yscale, y2); \
|
||||
} \
|
||||
|
@ -616,7 +610,7 @@
|
|||
(vertices)[2] = (x2); \
|
||||
(vertices)[4] = (vertices)[2]; \
|
||||
(vertices)[6] = (vertices)[0]; \
|
||||
if (likely(yInverted)) { \
|
||||
if (_X_LIKELY(yInverted)) { \
|
||||
(vertices)[1] = (y1); \
|
||||
(vertices)[5] = (y2); \
|
||||
} \
|
||||
|
@ -635,7 +629,7 @@
|
|||
(vertices)[1*stride] = (x2); \
|
||||
(vertices)[2*stride] = (vertices)[1*stride]; \
|
||||
(vertices)[3*stride] = (vertices)[0]; \
|
||||
if (likely(yInverted)) { \
|
||||
if (_X_LIKELY(yInverted)) { \
|
||||
(vertices)[1] = (y1); \
|
||||
(vertices)[2*stride + 1] = (y2); \
|
||||
} \
|
||||
|
@ -651,7 +645,7 @@
|
|||
yInverted, vertices) \
|
||||
do { \
|
||||
(vertices)[0] = v_from_x_coord_x(xscale, x); \
|
||||
if (likely(yInverted)) { \
|
||||
if (_X_LIKELY(yInverted)) { \
|
||||
(vertices)[1] = v_from_x_coord_y_inverted(yscale, y); \
|
||||
} else { \
|
||||
(vertices)[1] = v_from_x_coord_y(yscale, y); \
|
||||
|
@ -679,7 +673,7 @@
|
|||
(vertices)[2] = (x2); \
|
||||
(vertices)[6] = (vertices)[2]; \
|
||||
(vertices)[4] = (vertices)[0]; \
|
||||
if (likely(yInverted)) { \
|
||||
if (_X_LIKELY(yInverted)) { \
|
||||
(vertices)[1] = (y1); \
|
||||
(vertices)[7] = (y2); \
|
||||
} \
|
||||
|
@ -705,7 +699,7 @@
|
|||
x2 + fbo_x_off); \
|
||||
(vertices)[2 * stride] = _t2_; \
|
||||
(vertices)[3 * stride] = _t0_; \
|
||||
if (likely(yInverted)) { \
|
||||
if (_X_LIKELY(yInverted)) { \
|
||||
(vertices)[1] = _t1_ = v_from_x_coord_y_inverted(yscale, \
|
||||
y1 + fbo_y_off); \
|
||||
(vertices)[2 * stride + 1] = _t5_ = \
|
||||
|
@ -721,7 +715,6 @@
|
|||
(vertices)[3 * stride + 1] = _t5_; \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define glamor_set_normalize_vcoords(priv, xscale, yscale, \
|
||||
x1, y1, x2, y2, \
|
||||
yInverted, vertices) \
|
||||
|
@ -749,7 +742,7 @@
|
|||
(vertices)[2] = v_from_x_coord_x(xscale, x2); \
|
||||
(vertices)[6] = (vertices)[2]; \
|
||||
(vertices)[4] = (vertices)[0]; \
|
||||
if (likely(yInverted)) { \
|
||||
if (_X_LIKELY(yInverted)) { \
|
||||
(vertices)[1] = v_from_x_coord_y_inverted(yscale, y1); \
|
||||
(vertices)[7] = v_from_x_coord_y_inverted(yscale, y2); \
|
||||
} \
|
||||
|
@ -765,7 +758,7 @@
|
|||
yInverted, pt) \
|
||||
do { \
|
||||
(pt)[0] = t_from_x_coord_x(xscale, x); \
|
||||
if (likely(yInverted)) { \
|
||||
if (_X_LIKELY(yInverted)) { \
|
||||
(pt)[1] = t_from_x_coord_y_inverted(yscale, y); \
|
||||
} else { \
|
||||
(pt)[1] = t_from_x_coord_y(yscale, y); \
|
||||
|
@ -776,7 +769,7 @@
|
|||
yInverted, c) \
|
||||
do { \
|
||||
(c)[0] = (float)x; \
|
||||
if (likely(yInverted)) { \
|
||||
if (_X_LIKELY(yInverted)) { \
|
||||
(c)[1] = (float)y; \
|
||||
} else { \
|
||||
(c)[1] = (float)height - (float)y; \
|
||||
|
@ -789,6 +782,7 @@ glamor_calculate_boxes_bound(BoxPtr bound, BoxPtr boxes, int nbox)
|
|||
int x_min, y_min;
|
||||
int x_max, y_max;
|
||||
int i;
|
||||
|
||||
x_min = y_min = MAXSHORT;
|
||||
x_max = y_max = MINSHORT;
|
||||
for (i = 0; i < nbox; i++) {
|
||||
|
@ -812,6 +806,7 @@ inline static void
|
|||
glamor_translate_boxes(BoxPtr boxes, int nbox, int dx, int dy)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nbox; i++) {
|
||||
boxes[i].x1 += dx;
|
||||
boxes[i].y1 += dy;
|
||||
|
@ -820,12 +815,6 @@ glamor_translate_boxes(BoxPtr boxes, int nbox, int dx, int dy)
|
|||
}
|
||||
}
|
||||
|
||||
static inline Bool
|
||||
region_is_empty(pixman_region16_t *region)
|
||||
{
|
||||
return region->data && region->data->numRects == 0;
|
||||
}
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
||||
#endif
|
||||
|
@ -943,9 +932,7 @@ glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
|
|||
GLenum * tex_type,
|
||||
int *no_alpha,
|
||||
int *revert,
|
||||
int *swap_rb,
|
||||
int is_upload)
|
||||
|
||||
int *swap_rb, int is_upload)
|
||||
{
|
||||
*no_alpha = 0;
|
||||
*revert = REVERT_NONE;
|
||||
|
@ -1029,15 +1016,15 @@ glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
|
|||
|
||||
default:
|
||||
LogMessageVerb(X_INFO, 0,
|
||||
"fail to get matched format for %x \n",
|
||||
format);
|
||||
"fail to get matched format for %x \n", format);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Currently, we use RGBA to represent all formats. */
|
||||
inline static int cache_format(GLenum format)
|
||||
inline static int
|
||||
cache_format(GLenum format)
|
||||
{
|
||||
switch (format) {
|
||||
case GL_ALPHA:
|
||||
|
@ -1058,8 +1045,7 @@ glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
|
|||
GLenum * tex_type,
|
||||
int *no_alpha,
|
||||
int *revert,
|
||||
int *swap_rb,
|
||||
int is_upload)
|
||||
int *swap_rb, int is_upload)
|
||||
{
|
||||
int need_swap_rb = 0;
|
||||
|
||||
|
@ -1157,8 +1143,11 @@ glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
|
|||
*tex_format = GL_RGBA;
|
||||
*tex_type = GL_UNSIGNED_SHORT_5_5_5_1;
|
||||
if (IS_LITTLE_ENDIAN) {
|
||||
*revert = is_upload ? REVERT_UPLOADING_1_5_5_5 : REVERT_DOWNLOADING_1_5_5_5;
|
||||
} else
|
||||
*revert =
|
||||
is_upload ? REVERT_UPLOADING_1_5_5_5 :
|
||||
REVERT_DOWNLOADING_1_5_5_5;
|
||||
}
|
||||
else
|
||||
*revert = REVERT_NONE;
|
||||
break;
|
||||
|
||||
|
@ -1168,8 +1157,11 @@ glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
|
|||
*tex_format = GL_RGBA;
|
||||
*tex_type = GL_UNSIGNED_SHORT_5_5_5_1;
|
||||
if (IS_LITTLE_ENDIAN) {
|
||||
*revert = is_upload ? REVERT_UPLOADING_1_5_5_5 : REVERT_DOWNLOADING_1_5_5_5;
|
||||
} else
|
||||
*revert =
|
||||
is_upload ? REVERT_UPLOADING_1_5_5_5 :
|
||||
REVERT_DOWNLOADING_1_5_5_5;
|
||||
}
|
||||
else
|
||||
*revert = REVERT_NONE;
|
||||
need_swap_rb = 1;
|
||||
break;
|
||||
|
@ -1205,8 +1197,7 @@ glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
|
|||
|
||||
default:
|
||||
LogMessageVerb(X_INFO, 0,
|
||||
"fail to get matched format for %x \n",
|
||||
format);
|
||||
"fail to get matched format for %x \n", format);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1217,7 +1208,8 @@ glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
|
|||
return 0;
|
||||
}
|
||||
|
||||
inline static int cache_format(GLenum format)
|
||||
inline static int
|
||||
cache_format(GLenum format)
|
||||
{
|
||||
switch (format) {
|
||||
case GL_ALPHA:
|
||||
|
@ -1233,15 +1225,12 @@ inline static int cache_format(GLenum format)
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
static inline int
|
||||
glamor_get_tex_format_type_from_pixmap(PixmapPtr pixmap,
|
||||
GLenum * format,
|
||||
GLenum * type,
|
||||
int *no_alpha,
|
||||
int *revert,
|
||||
int *swap_rb,
|
||||
int is_upload)
|
||||
int *revert, int *swap_rb, int is_upload)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
PictFormatShort pict_format;
|
||||
|
@ -1256,11 +1245,9 @@ glamor_get_tex_format_type_from_pixmap(PixmapPtr pixmap,
|
|||
format, type,
|
||||
no_alpha,
|
||||
revert,
|
||||
swap_rb,
|
||||
is_upload);
|
||||
swap_rb, is_upload);
|
||||
}
|
||||
|
||||
|
||||
/* borrowed from uxa */
|
||||
static inline Bool
|
||||
glamor_get_rgba_from_pixel(CARD32 pixel,
|
||||
|
@ -1278,27 +1265,30 @@ glamor_get_rgba_from_pixel(CARD32 pixel,
|
|||
|
||||
if (PICT_FORMAT_TYPE(format) == PICT_TYPE_A) {
|
||||
rshift = gshift = bshift = ashift = 0;
|
||||
} else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ARGB) {
|
||||
}
|
||||
else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ARGB) {
|
||||
bshift = 0;
|
||||
gshift = bbits;
|
||||
rshift = gshift + gbits;
|
||||
ashift = rshift + rbits;
|
||||
} else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ABGR) {
|
||||
}
|
||||
else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ABGR) {
|
||||
rshift = 0;
|
||||
gshift = rbits;
|
||||
bshift = gshift + gbits;
|
||||
ashift = bshift + bbits;
|
||||
#if XORG_VERSION_CURRENT >= 10699900
|
||||
} else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_BGRA) {
|
||||
}
|
||||
else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_BGRA) {
|
||||
ashift = 0;
|
||||
rshift = abits;
|
||||
if (abits == 0)
|
||||
rshift = PICT_FORMAT_BPP(format) - (rbits + gbits +
|
||||
bbits);
|
||||
rshift = PICT_FORMAT_BPP(format) - (rbits + gbits + bbits);
|
||||
gshift = rshift + rbits;
|
||||
bshift = gshift + gbits;
|
||||
#endif
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return FALSE;
|
||||
}
|
||||
#define COLOR_INT_TO_FLOAT(_fc_, _p_, _s_, _bits_) \
|
||||
|
@ -1328,7 +1318,8 @@ glamor_get_rgba_from_pixel(CARD32 pixel,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
inline static Bool glamor_pict_format_is_compatible(PictFormatShort pict_format, int depth)
|
||||
inline static Bool
|
||||
glamor_pict_format_is_compatible(PictFormatShort pict_format, int depth)
|
||||
{
|
||||
GLenum iformat;
|
||||
|
||||
|
@ -1344,19 +1335,23 @@ inline static Bool glamor_pict_format_is_compatible(PictFormatShort pict_format,
|
|||
}
|
||||
|
||||
/* return TRUE if we can access this pixmap at DDX driver. */
|
||||
inline static Bool glamor_ddx_fallback_check_pixmap(DrawablePtr drawable)
|
||||
inline static Bool
|
||||
glamor_ddx_fallback_check_pixmap(DrawablePtr drawable)
|
||||
{
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
return (!pixmap_priv
|
||||
|| (pixmap_priv->type == GLAMOR_TEXTURE_DRM
|
||||
|| pixmap_priv->type == GLAMOR_MEMORY
|
||||
|| pixmap_priv->type == GLAMOR_DRM_ONLY));
|
||||
}
|
||||
|
||||
inline static Bool glamor_ddx_fallback_check_gc(GCPtr gc)
|
||||
inline static Bool
|
||||
glamor_ddx_fallback_check_gc(GCPtr gc)
|
||||
{
|
||||
PixmapPtr pixmap;
|
||||
|
||||
if (!gc)
|
||||
return TRUE;
|
||||
switch (gc->fillStyle) {
|
||||
|
@ -1372,7 +1367,9 @@ inline static Bool glamor_ddx_fallback_check_gc(GCPtr gc)
|
|||
}
|
||||
return (!pixmap || glamor_ddx_fallback_check_pixmap(&pixmap->drawable));
|
||||
}
|
||||
inline static Bool glamor_is_large_pixmap(PixmapPtr pixmap)
|
||||
|
||||
inline static Bool
|
||||
glamor_is_large_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_private *priv;
|
||||
|
||||
|
@ -1380,7 +1377,8 @@ inline static Bool glamor_is_large_pixmap(PixmapPtr pixmap)
|
|||
return (priv->type == GLAMOR_TEXTURE_LARGE);
|
||||
}
|
||||
|
||||
inline static Bool glamor_is_large_picture(PicturePtr picture)
|
||||
inline static Bool
|
||||
glamor_is_large_picture(PicturePtr picture)
|
||||
{
|
||||
PixmapPtr pixmap;
|
||||
|
||||
|
@ -1391,85 +1389,87 @@ inline static Bool glamor_is_large_picture(PicturePtr picture)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
inline static Bool glamor_tex_format_is_readable(GLenum format)
|
||||
inline static Bool
|
||||
glamor_tex_format_is_readable(GLenum format)
|
||||
{
|
||||
return ((format == GL_RGBA || format == GL_RGB || format == GL_ALPHA));
|
||||
|
||||
}
|
||||
|
||||
static inline void _glamor_dump_pixmap_bits(PixmapPtr pixmap, int x, int y, int w, int h)
|
||||
static inline void
|
||||
_glamor_dump_pixmap_bits(PixmapPtr pixmap, int x, int y, int w, int h)
|
||||
{
|
||||
int i,j;
|
||||
unsigned char * p = pixmap->devPrivate.ptr;
|
||||
int i, j;
|
||||
unsigned char *p = pixmap->devPrivate.ptr;
|
||||
int stride = pixmap->devKind;
|
||||
|
||||
p = p + y * stride + x;
|
||||
|
||||
for (i = 0; i < h; i++)
|
||||
{
|
||||
for (i = 0; i < h; i++) {
|
||||
ErrorF("line %3d: ", i);
|
||||
for(j = 0; j < w; j++)
|
||||
ErrorF("%2d ", (p[j/8] & (1 << (j%8)))>>(j%8));
|
||||
for (j = 0; j < w; j++)
|
||||
ErrorF("%2d ", (p[j / 8] & (1 << (j % 8))) >> (j % 8));
|
||||
p += stride;
|
||||
ErrorF("\n");
|
||||
}
|
||||
}
|
||||
|
||||
static inline void _glamor_dump_pixmap_byte(PixmapPtr pixmap, int x, int y, int w, int h)
|
||||
static inline void
|
||||
_glamor_dump_pixmap_byte(PixmapPtr pixmap, int x, int y, int w, int h)
|
||||
{
|
||||
int i,j;
|
||||
unsigned char * p = pixmap->devPrivate.ptr;
|
||||
int i, j;
|
||||
unsigned char *p = pixmap->devPrivate.ptr;
|
||||
int stride = pixmap->devKind;
|
||||
|
||||
p = p + y * stride + x;
|
||||
|
||||
for (i = 0; i < h; i++)
|
||||
{
|
||||
for (i = 0; i < h; i++) {
|
||||
ErrorF("line %3d: ", i);
|
||||
for(j = 0; j < w; j++)
|
||||
for (j = 0; j < w; j++)
|
||||
ErrorF("%2x ", p[j]);
|
||||
p += stride;
|
||||
ErrorF("\n");
|
||||
}
|
||||
}
|
||||
|
||||
static inline void _glamor_dump_pixmap_sword(PixmapPtr pixmap, int x, int y, int w, int h)
|
||||
static inline void
|
||||
_glamor_dump_pixmap_sword(PixmapPtr pixmap, int x, int y, int w, int h)
|
||||
{
|
||||
int i,j;
|
||||
unsigned short * p = pixmap->devPrivate.ptr;
|
||||
int i, j;
|
||||
unsigned short *p = pixmap->devPrivate.ptr;
|
||||
int stride = pixmap->devKind / 2;
|
||||
|
||||
p = p + y * stride + x;
|
||||
|
||||
for (i = 0; i < h; i++)
|
||||
{
|
||||
for (i = 0; i < h; i++) {
|
||||
ErrorF("line %3d: ", i);
|
||||
for(j = 0; j < w; j++)
|
||||
for (j = 0; j < w; j++)
|
||||
ErrorF("%2x ", p[j]);
|
||||
p += stride;
|
||||
ErrorF("\n");
|
||||
}
|
||||
}
|
||||
|
||||
static inline void _glamor_dump_pixmap_word(PixmapPtr pixmap, int x, int y, int w, int h)
|
||||
static inline void
|
||||
_glamor_dump_pixmap_word(PixmapPtr pixmap, int x, int y, int w, int h)
|
||||
{
|
||||
int i,j;
|
||||
unsigned int * p = pixmap->devPrivate.ptr;
|
||||
int i, j;
|
||||
unsigned int *p = pixmap->devPrivate.ptr;
|
||||
int stride = pixmap->devKind / 4;
|
||||
|
||||
p = p + y * stride + x;
|
||||
|
||||
for (i = 0; i < h; i++)
|
||||
{
|
||||
for (i = 0; i < h; i++) {
|
||||
ErrorF("line %3d: ", i);
|
||||
for(j = 0; j < w; j++)
|
||||
for (j = 0; j < w; j++)
|
||||
ErrorF("%2x ", p[j]);
|
||||
p += stride;
|
||||
ErrorF("\n");
|
||||
}
|
||||
}
|
||||
|
||||
static inline void glamor_dump_pixmap(PixmapPtr pixmap, int x, int y, int w, int h)
|
||||
static inline void
|
||||
glamor_dump_pixmap(PixmapPtr pixmap, int x, int y, int w, int h)
|
||||
{
|
||||
w = ((x + w) > pixmap->drawable.width) ? (pixmap->drawable.width - x) : w;
|
||||
h = ((y + h) > pixmap->drawable.height) ? (pixmap->drawable.height - y) : h;
|
||||
|
@ -1497,14 +1497,14 @@ static inline void glamor_dump_pixmap(PixmapPtr pixmap, int x, int y, int w, int
|
|||
glamor_finish_access(&pixmap->drawable, GLAMOR_ACCESS_RO);
|
||||
}
|
||||
|
||||
static inline void _glamor_compare_pixmaps(PixmapPtr pixmap1, PixmapPtr pixmap2,
|
||||
static inline void
|
||||
_glamor_compare_pixmaps(PixmapPtr pixmap1, PixmapPtr pixmap2,
|
||||
int x, int y, int w, int h,
|
||||
PictFormatShort short_format,
|
||||
int all, int diffs)
|
||||
PictFormatShort short_format, int all, int diffs)
|
||||
{
|
||||
int i, j;
|
||||
unsigned char * p1 = pixmap1->devPrivate.ptr;
|
||||
unsigned char * p2 = pixmap2->devPrivate.ptr;
|
||||
unsigned char *p1 = pixmap1->devPrivate.ptr;
|
||||
unsigned char *p2 = pixmap2->devPrivate.ptr;
|
||||
int line_need_printed = 0;
|
||||
int test_code = 0xAABBCCDD;
|
||||
int little_endian = 0;
|
||||
|
@ -1534,9 +1534,10 @@ static inline void _glamor_compare_pixmaps(PixmapPtr pixmap1, PixmapPtr pixmap2,
|
|||
p2 += stride;
|
||||
ErrorF("\n");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (short_format == PICT_a8r8g8b8) {
|
||||
p_test = (unsigned char *) & test_code;
|
||||
p_test = (unsigned char *) &test_code;
|
||||
little_endian = (*p_test == 0xDD);
|
||||
bpp = 4;
|
||||
|
||||
|
@ -1544,40 +1545,51 @@ static inline void _glamor_compare_pixmaps(PixmapPtr pixmap1, PixmapPtr pixmap2,
|
|||
line_need_printed = 0;
|
||||
|
||||
for (j = 0; j < stride; j++) {
|
||||
if (p1[j] != p2[j] && (p1[j] - p2[j] > diffs || p2[j] - p1[j] > diffs)) {
|
||||
if (p1[j] != p2[j] &&
|
||||
(p1[j] - p2[j] > diffs || p2[j] - p1[j] > diffs)) {
|
||||
if (line_need_printed) {
|
||||
if (little_endian) {
|
||||
switch (j % 4) {
|
||||
case 2:
|
||||
ErrorF("[%d]RED:%2x:%2x ", j / bpp, p1[j], p2[j]);
|
||||
ErrorF("[%d]RED:%2x:%2x ", j / bpp, p1[j],
|
||||
p2[j]);
|
||||
break;
|
||||
case 1:
|
||||
ErrorF("[%d]GREEN:%2x:%2x ", j / bpp, p1[j], p2[j]);
|
||||
ErrorF("[%d]GREEN:%2x:%2x ", j / bpp, p1[j],
|
||||
p2[j]);
|
||||
break;
|
||||
case 0:
|
||||
ErrorF("[%d]BLUE:%2x:%2x ", j / bpp, p1[j], p2[j]);
|
||||
ErrorF("[%d]BLUE:%2x:%2x ", j / bpp, p1[j],
|
||||
p2[j]);
|
||||
break;
|
||||
case 3:
|
||||
ErrorF("[%d]Alpha:%2x:%2x ", j / bpp, p1[j], p2[j]);
|
||||
ErrorF("[%d]Alpha:%2x:%2x ", j / bpp, p1[j],
|
||||
p2[j]);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
switch (j % 4) {
|
||||
case 1:
|
||||
ErrorF("[%d]RED:%2x:%2x ", j / bpp, p1[j], p2[j]);
|
||||
ErrorF("[%d]RED:%2x:%2x ", j / bpp, p1[j],
|
||||
p2[j]);
|
||||
break;
|
||||
case 2:
|
||||
ErrorF("[%d]GREEN:%2x:%2x ", j / bpp, p1[j], p2[j]);
|
||||
ErrorF("[%d]GREEN:%2x:%2x ", j / bpp, p1[j],
|
||||
p2[j]);
|
||||
break;
|
||||
case 3:
|
||||
ErrorF("[%d]BLUE:%2x:%2x ", j / bpp, p1[j], p2[j]);
|
||||
ErrorF("[%d]BLUE:%2x:%2x ", j / bpp, p1[j],
|
||||
p2[j]);
|
||||
break;
|
||||
case 0:
|
||||
ErrorF("[%d]Alpha:%2x:%2x ", j / bpp, p1[j], p2[j]);
|
||||
ErrorF("[%d]Alpha:%2x:%2x ", j / bpp, p1[j],
|
||||
p2[j]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
line_need_printed = 1;
|
||||
j = -1;
|
||||
ErrorF("line %3d: ", i);
|
||||
|
@ -1599,7 +1611,8 @@ static inline void _glamor_compare_pixmaps(PixmapPtr pixmap1, PixmapPtr pixmap2,
|
|||
if (p1[j] != p2[j]) {
|
||||
if (line_need_printed) {
|
||||
ErrorF("[%d]%2x:%2x ", j / bpp, p1[j], p2[j]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
line_need_printed = 1;
|
||||
j = -1;
|
||||
ErrorF("line %3d: ", i);
|
||||
|
@ -1616,7 +1629,8 @@ static inline void _glamor_compare_pixmaps(PixmapPtr pixmap1, PixmapPtr pixmap2,
|
|||
}
|
||||
}
|
||||
|
||||
static inline void glamor_compare_pixmaps(PixmapPtr pixmap1, PixmapPtr pixmap2,
|
||||
static inline void
|
||||
glamor_compare_pixmaps(PixmapPtr pixmap1, PixmapPtr pixmap2,
|
||||
int x, int y, int w, int h, int all, int diffs)
|
||||
{
|
||||
assert(pixmap1->drawable.depth == pixmap2->drawable.depth);
|
||||
|
@ -1632,12 +1646,12 @@ static inline void glamor_compare_pixmaps(PixmapPtr pixmap1, PixmapPtr pixmap2,
|
|||
|
||||
/* This function is used to compare two pictures.
|
||||
If the picture has no drawable, we use fb functions to generate it. */
|
||||
static inline void glamor_compare_pictures( ScreenPtr screen,
|
||||
static inline void
|
||||
glamor_compare_pictures(ScreenPtr screen,
|
||||
PicturePtr fst_picture,
|
||||
PicturePtr snd_picture,
|
||||
int x_source, int y_source,
|
||||
int width, int height,
|
||||
int all, int diffs)
|
||||
int width, int height, int all, int diffs)
|
||||
{
|
||||
PixmapPtr fst_pixmap;
|
||||
PixmapPtr snd_pixmap;
|
||||
|
@ -1681,14 +1695,12 @@ static inline void glamor_compare_pictures( ScreenPtr screen,
|
|||
pixman_pic = CreatePicture(0,
|
||||
&pixmap->drawable,
|
||||
PictureMatchFormat(screen,
|
||||
PIXMAN_FORMAT_DEPTH(format), format),
|
||||
0, 0, serverClient, &error);
|
||||
PIXMAN_FORMAT_DEPTH
|
||||
(format), format), 0, 0,
|
||||
serverClient, &error);
|
||||
|
||||
fbComposite(PictOpSrc, fst_picture, NULL, pixman_pic,
|
||||
x_source, y_source,
|
||||
0, 0,
|
||||
0, 0,
|
||||
width, height);
|
||||
x_source, y_source, 0, 0, 0, 0, width, height);
|
||||
|
||||
glamor_destroy_pixmap(pixmap);
|
||||
|
||||
|
@ -1711,14 +1723,12 @@ static inline void glamor_compare_pictures( ScreenPtr screen,
|
|||
pixman_pic = CreatePicture(0,
|
||||
&pixmap->drawable,
|
||||
PictureMatchFormat(screen,
|
||||
PIXMAN_FORMAT_DEPTH(format), format),
|
||||
0, 0, serverClient, &error);
|
||||
PIXMAN_FORMAT_DEPTH
|
||||
(format), format), 0, 0,
|
||||
serverClient, &error);
|
||||
|
||||
fbComposite(PictOpSrc, snd_picture, NULL, pixman_pic,
|
||||
x_source, y_source,
|
||||
0, 0,
|
||||
0, 0,
|
||||
width, height);
|
||||
x_source, y_source, 0, 0, 0, 0, width, height);
|
||||
|
||||
glamor_destroy_pixmap(pixmap);
|
||||
|
||||
|
@ -1753,8 +1763,7 @@ static inline void glamor_compare_pictures( ScreenPtr screen,
|
|||
|
||||
_glamor_compare_pixmaps(fst_pixmap, snd_pixmap,
|
||||
x_source, y_source,
|
||||
width, height,
|
||||
fst_picture->format, all, diffs);
|
||||
width, height, fst_picture->format, all, diffs);
|
||||
|
||||
glamor_finish_access(&fst_pixmap->drawable, GLAMOR_ACCESS_RO);
|
||||
glamor_finish_access(&snd_pixmap->drawable, GLAMOR_ACCESS_RO);
|
||||
|
@ -1768,42 +1777,59 @@ static inline void glamor_compare_pictures( ScreenPtr screen,
|
|||
}
|
||||
|
||||
#ifdef __i386__
|
||||
static inline unsigned long __fls(unsigned long x)
|
||||
static inline unsigned long
|
||||
__fls(unsigned long x)
|
||||
{
|
||||
asm("bsr %1,%0"
|
||||
: "=r" (x)
|
||||
: "rm" (x));
|
||||
asm("bsr %1,%0":"=r"(x)
|
||||
: "rm"(x));
|
||||
return x;
|
||||
}
|
||||
#else
|
||||
static inline unsigned long __fls(unsigned long x)
|
||||
static inline unsigned long
|
||||
__fls(unsigned long x)
|
||||
{
|
||||
int n;
|
||||
|
||||
if (x == 0) return(0);
|
||||
if (x == 0)
|
||||
return (0);
|
||||
n = 0;
|
||||
if (x <= 0x0000FFFF) {n = n +16; x = x <<16;}
|
||||
if (x <= 0x00FFFFFF) {n = n + 8; x = x << 8;}
|
||||
if (x <= 0x0FFFFFFF) {n = n + 4; x = x << 4;}
|
||||
if (x <= 0x3FFFFFFF) {n = n + 2; x = x << 2;}
|
||||
if (x <= 0x7FFFFFFF) {n = n + 1;}
|
||||
if (x <= 0x0000FFFF) {
|
||||
n = n + 16;
|
||||
x = x << 16;
|
||||
}
|
||||
if (x <= 0x00FFFFFF) {
|
||||
n = n + 8;
|
||||
x = x << 8;
|
||||
}
|
||||
if (x <= 0x0FFFFFFF) {
|
||||
n = n + 4;
|
||||
x = x << 4;
|
||||
}
|
||||
if (x <= 0x3FFFFFFF) {
|
||||
n = n + 2;
|
||||
x = x << 2;
|
||||
}
|
||||
if (x <= 0x7FFFFFFF) {
|
||||
n = n + 1;
|
||||
}
|
||||
return 31 - n;
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void glamor_make_current(ScreenPtr screen)
|
||||
static inline void
|
||||
glamor_make_current(ScreenPtr screen)
|
||||
{
|
||||
glamor_egl_make_current(screen);
|
||||
}
|
||||
|
||||
static inline void glamor_restore_current(ScreenPtr screen)
|
||||
static inline void
|
||||
glamor_restore_current(ScreenPtr screen)
|
||||
{
|
||||
glamor_egl_restore_context(screen);
|
||||
}
|
||||
|
||||
#ifdef GLX_USE_SHARED_DISPATCH
|
||||
static inline glamor_gl_dispatch *
|
||||
glamor_get_dispatch(glamor_screen_private *glamor_priv)
|
||||
glamor_get_dispatch(glamor_screen_private * glamor_priv)
|
||||
{
|
||||
if (glamor_priv->flags & GLAMOR_USE_EGL_SCREEN)
|
||||
glamor_make_current(glamor_priv->screen);
|
||||
|
@ -1812,24 +1838,10 @@ glamor_get_dispatch(glamor_screen_private *glamor_priv)
|
|||
}
|
||||
|
||||
static inline void
|
||||
glamor_put_dispatch(glamor_screen_private *glamor_priv)
|
||||
glamor_put_dispatch(glamor_screen_private * glamor_priv)
|
||||
{
|
||||
if (glamor_priv->flags & GLAMOR_USE_EGL_SCREEN)
|
||||
glamor_restore_current(glamor_priv->screen);
|
||||
}
|
||||
#else
|
||||
#warning "Indirect GLX may be broken, need to implement context switch."
|
||||
static inline glamor_gl_dispatch *
|
||||
glamor_get_dispatch(glamor_screen_private *glamor_priv)
|
||||
{
|
||||
return &glamor_priv->_dispatch;
|
||||
}
|
||||
|
||||
static inline void
|
||||
glamor_put_dispatch(glamor_screen_private *glamor_priv)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -28,9 +28,8 @@
|
|||
* Screen Change Window Attribute implementation.
|
||||
*/
|
||||
|
||||
|
||||
static void
|
||||
glamor_fixup_window_pixmap(DrawablePtr pDrawable, PixmapPtr * ppPixmap)
|
||||
glamor_fixup_window_pixmap(DrawablePtr pDrawable, PixmapPtr *ppPixmap)
|
||||
{
|
||||
PixmapPtr pPixmap = *ppPixmap;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
|
@ -41,8 +40,7 @@ glamor_fixup_window_pixmap(DrawablePtr pDrawable, PixmapPtr * ppPixmap)
|
|||
glamor_fallback("pixmap %p has no fbo\n", pPixmap);
|
||||
goto fail;
|
||||
}
|
||||
glamor_debug_output(GLAMOR_DEBUG_UNIMPL,
|
||||
"To be implemented.\n");
|
||||
glamor_debug_output(GLAMOR_DEBUG_UNIMPL, "To be implemented.\n");
|
||||
}
|
||||
return;
|
||||
|
||||
|
@ -58,14 +56,12 @@ glamor_change_window_attributes(WindowPtr pWin, unsigned long mask)
|
|||
if (mask & CWBackPixmap) {
|
||||
if (pWin->backgroundState == BackgroundPixmap)
|
||||
glamor_fixup_window_pixmap(&pWin->drawable,
|
||||
&pWin->
|
||||
background.pixmap);
|
||||
&pWin->background.pixmap);
|
||||
}
|
||||
|
||||
if (mask & CWBorderPixmap) {
|
||||
if (pWin->borderIsPixel == FALSE)
|
||||
glamor_fixup_window_pixmap(&pWin->drawable,
|
||||
&pWin->border.pixmap);
|
||||
glamor_fixup_window_pixmap(&pWin->drawable, &pWin->border.pixmap);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -74,8 +70,7 @@ void
|
|||
glamor_set_window_pixmap(WindowPtr win, PixmapPtr pPixmap)
|
||||
{
|
||||
ScreenPtr screen = win->drawable.pScreen;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
PixmapPtr old = screen->GetWindowPixmap(win);
|
||||
|
||||
if (pPixmap != old) {
|
||||
|
@ -83,7 +78,8 @@ glamor_set_window_pixmap(WindowPtr win, PixmapPtr pPixmap)
|
|||
PicturePtr pic = NULL;
|
||||
|
||||
pixmap_priv = glamor_get_pixmap_private(old);
|
||||
if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv) && pixmap_priv->base.picture->pDrawable == (DrawablePtr)win) {
|
||||
if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv) &&
|
||||
pixmap_priv->base.picture->pDrawable == (DrawablePtr) win) {
|
||||
pic = pixmap_priv->base.picture;
|
||||
pixmap_priv->base.is_picture = 0;
|
||||
pixmap_priv->base.picture = NULL;
|
||||
|
@ -91,13 +87,13 @@ glamor_set_window_pixmap(WindowPtr win, PixmapPtr pPixmap)
|
|||
|
||||
pixmap_priv = glamor_get_pixmap_private(pPixmap);
|
||||
if (pixmap_priv) {
|
||||
pixmap_priv->base.is_picture = !!pic;
|
||||
pixmap_priv->base.is_picture = ! !pic;
|
||||
pixmap_priv->base.picture = pic;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
screen->SetWindowPixmap = glamor_set_window_pixmap;
|
||||
}
|
||||
|
|
|
@ -39,8 +39,7 @@
|
|||
#include <X11/extensions/Xv.h>
|
||||
#include "fourcc.h"
|
||||
/* Reference color space transform data */
|
||||
typedef struct tagREF_TRANSFORM
|
||||
{
|
||||
typedef struct tagREF_TRANSFORM {
|
||||
float RefLuma;
|
||||
float RefRCb;
|
||||
float RefRCr;
|
||||
|
@ -56,10 +55,12 @@ typedef struct tagREF_TRANSFORM
|
|||
#define RTFContrast(a) (1.0 + ((a)*1.0)/1000.0)
|
||||
#define RTFHue(a) (((a)*3.1416)/1000.0)
|
||||
|
||||
static const char *xv_vs= "attribute vec4 v_position;\n"
|
||||
static const char *xv_vs = "attribute vec4 v_position;\n"
|
||||
"attribute vec4 v_texcoord0;\n"
|
||||
"varying vec2 tcs;\n"
|
||||
"void main()\n" "{\n" " gl_Position = v_position;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = v_position;\n"
|
||||
"tcs = v_texcoord0.xy;\n"
|
||||
"}\n";
|
||||
|
||||
|
@ -73,7 +74,8 @@ static const char *xv_ps = GLAMOR_DEFAULT_PRECISION
|
|||
"varying vec2 tcs;\n"
|
||||
"float sample;\n"
|
||||
"vec4 temp1;\n"
|
||||
"void main()\n" "{\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
"sample = texture2D(y_sampler, tcs).w;\n"
|
||||
"temp1.xyz = offsetyco.www * vec3(sample) + offsetyco.xyz;\n"
|
||||
"sample = texture2D(u_sampler, tcs).w;\n"
|
||||
|
@ -125,97 +127,94 @@ glamor_fini_xv_shader(ScreenPtr screen)
|
|||
#define ClipValue(v,min,max) ((v) < (min) ? (min) : (v) > (max) ? (max) : (v))
|
||||
#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
|
||||
|
||||
static Atom xvBrightness, xvContrast, xvSaturation, xvHue, xvColorspace, xvGamma;
|
||||
static Atom xvBrightness, xvContrast, xvSaturation, xvHue, xvColorspace,
|
||||
xvGamma;
|
||||
|
||||
#define NUM_ATTRIBUTES 5
|
||||
static XF86AttributeRec Attributes_glamor[NUM_ATTRIBUTES+1] =
|
||||
{
|
||||
static XF86AttributeRec Attributes_glamor[NUM_ATTRIBUTES + 1] = {
|
||||
{XvSettable | XvGettable, -1000, 1000, "XV_BRIGHTNESS"},
|
||||
{XvSettable | XvGettable, -1000, 1000, "XV_CONTRAST"},
|
||||
{XvSettable | XvGettable, -1000, 1000, "XV_SATURATION"},
|
||||
{XvSettable | XvGettable, -1000, 1000, "XV_HUE"},
|
||||
{XvSettable | XvGettable, 0, 1, "XV_COLORSPACE"},
|
||||
{0, 0, 0, NULL}
|
||||
};
|
||||
};
|
||||
|
||||
#define NUM_FORMATS 3
|
||||
|
||||
static XF86VideoFormatRec Formats[NUM_FORMATS] =
|
||||
{
|
||||
static XF86VideoFormatRec Formats[NUM_FORMATS] = {
|
||||
{15, TrueColor}, {16, TrueColor}, {24, TrueColor}
|
||||
};
|
||||
};
|
||||
|
||||
#define NUM_IMAGES 2
|
||||
|
||||
static XF86ImageRec Images[NUM_IMAGES] =
|
||||
{
|
||||
XVIMAGE_YV12,
|
||||
static XF86ImageRec Images[NUM_IMAGES] = {
|
||||
XVIMAGE_YV12,
|
||||
XVIMAGE_I420,
|
||||
};
|
||||
};
|
||||
|
||||
static void
|
||||
glamor_xv_stop_video(ScrnInfoPtr pScrn, pointer data, Bool cleanup)
|
||||
glamor_xv_stop_video(ScrnInfoPtr pScrn, void *data, Bool cleanup)
|
||||
{
|
||||
glamor_port_private *port_priv = (glamor_port_private *)data;
|
||||
int i;
|
||||
if (!cleanup)
|
||||
glamor_port_private *port_priv = (glamor_port_private *) data;
|
||||
int i;
|
||||
|
||||
if (!cleanup)
|
||||
return;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (port_priv->src_pix[i]) {
|
||||
glamor_destroy_pixmap(port_priv->src_pix[i]);
|
||||
port_priv->src_pix[i] = NULL;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (port_priv->src_pix[i]) {
|
||||
glamor_destroy_pixmap(port_priv->src_pix[i]);
|
||||
port_priv->src_pix[i] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
glamor_xv_set_port_attribute(ScrnInfoPtr pScrn,
|
||||
Atom attribute,
|
||||
INT32 value,
|
||||
pointer data)
|
||||
Atom attribute, INT32 value, void *data)
|
||||
{
|
||||
glamor_port_private *port_priv = (glamor_port_private *)data;
|
||||
if (attribute == xvBrightness)
|
||||
glamor_port_private *port_priv = (glamor_port_private *) data;
|
||||
|
||||
if (attribute == xvBrightness)
|
||||
port_priv->brightness = ClipValue(value, -1000, 1000);
|
||||
else if (attribute == xvHue)
|
||||
else if (attribute == xvHue)
|
||||
port_priv->hue = ClipValue(value, -1000, 1000);
|
||||
else if (attribute == xvContrast)
|
||||
else if (attribute == xvContrast)
|
||||
port_priv->contrast = ClipValue(value, -1000, 1000);
|
||||
else if (attribute == xvSaturation)
|
||||
else if (attribute == xvSaturation)
|
||||
port_priv->saturation = ClipValue(value, -1000, 1000);
|
||||
else if (attribute == xvGamma)
|
||||
port_priv->gamma = ClipValue (value, 100, 10000);
|
||||
else if(attribute == xvColorspace)
|
||||
port_priv->transform_index = ClipValue (value, 0, 1);
|
||||
else
|
||||
else if (attribute == xvGamma)
|
||||
port_priv->gamma = ClipValue(value, 100, 10000);
|
||||
else if (attribute == xvColorspace)
|
||||
port_priv->transform_index = ClipValue(value, 0, 1);
|
||||
else
|
||||
return BadMatch;
|
||||
return Success;
|
||||
return Success;
|
||||
}
|
||||
|
||||
static int
|
||||
glamor_xv_get_port_attribute(ScrnInfoPtr pScrn,
|
||||
Atom attribute,
|
||||
INT32 *value,
|
||||
pointer data)
|
||||
Atom attribute, INT32 *value, void *data)
|
||||
{
|
||||
glamor_port_private *port_priv = (glamor_port_private *)data;
|
||||
if (attribute == xvBrightness)
|
||||
glamor_port_private *port_priv = (glamor_port_private *) data;
|
||||
|
||||
if (attribute == xvBrightness)
|
||||
*value = port_priv->brightness;
|
||||
else if (attribute == xvHue)
|
||||
else if (attribute == xvHue)
|
||||
*value = port_priv->hue;
|
||||
else if (attribute == xvContrast)
|
||||
else if (attribute == xvContrast)
|
||||
*value = port_priv->contrast;
|
||||
else if (attribute == xvSaturation)
|
||||
else if (attribute == xvSaturation)
|
||||
*value = port_priv->saturation;
|
||||
else if (attribute == xvGamma)
|
||||
else if (attribute == xvGamma)
|
||||
*value = port_priv->gamma;
|
||||
else if(attribute == xvColorspace)
|
||||
else if (attribute == xvColorspace)
|
||||
*value = port_priv->transform_index;
|
||||
else
|
||||
else
|
||||
return BadMatch;
|
||||
|
||||
return Success;
|
||||
return Success;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -223,11 +222,10 @@ glamor_xv_query_best_size(ScrnInfoPtr pScrn,
|
|||
Bool motion,
|
||||
short vid_w, short vid_h,
|
||||
short drw_w, short drw_h,
|
||||
unsigned int *p_w, unsigned int *p_h,
|
||||
pointer data)
|
||||
unsigned int *p_w, unsigned int *p_h, void *data)
|
||||
{
|
||||
*p_w = drw_w;
|
||||
*p_h = drw_h;
|
||||
*p_w = drw_w;
|
||||
*p_h = drw_h;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -236,216 +234,203 @@ glamor_xv_query_image_attributes(ScrnInfoPtr pScrn,
|
|||
unsigned short *w, unsigned short *h,
|
||||
int *pitches, int *offsets)
|
||||
{
|
||||
int size = 0, tmp;
|
||||
int size = 0, tmp;
|
||||
|
||||
if (offsets) offsets[0] = 0;
|
||||
switch (id) {
|
||||
case FOURCC_YV12:
|
||||
case FOURCC_I420:
|
||||
*h = *h;
|
||||
*w = *w;
|
||||
size = *w;
|
||||
if (pitches) pitches[0] = size;
|
||||
size *= *h;
|
||||
if (offsets) offsets[1] = size;
|
||||
tmp = *w >> 1;
|
||||
if (pitches) pitches[1] = pitches[2] = tmp;
|
||||
tmp *= (*h >> 1);
|
||||
size += tmp;
|
||||
if (offsets) offsets[2] = size;
|
||||
size += tmp;
|
||||
break;
|
||||
}
|
||||
return size;
|
||||
if (offsets)
|
||||
offsets[0] = 0;
|
||||
switch (id) {
|
||||
case FOURCC_YV12:
|
||||
case FOURCC_I420:
|
||||
*h = *h;
|
||||
*w = *w;
|
||||
size = *w;
|
||||
if (pitches)
|
||||
pitches[0] = size;
|
||||
size *= *h;
|
||||
if (offsets)
|
||||
offsets[1] = size;
|
||||
tmp = *w >> 1;
|
||||
if (pitches)
|
||||
pitches[1] = pitches[2] = tmp;
|
||||
tmp *= (*h >> 1);
|
||||
size += tmp;
|
||||
if (offsets)
|
||||
offsets[2] = size;
|
||||
size += tmp;
|
||||
break;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
/* Parameters for ITU-R BT.601 and ITU-R BT.709 colour spaces
|
||||
note the difference to the parameters used in overlay are due
|
||||
to 10bit vs. float calcs */
|
||||
static REF_TRANSFORM trans[2] =
|
||||
{
|
||||
static REF_TRANSFORM trans[2] = {
|
||||
{1.1643, 0.0, 1.5960, -0.3918, -0.8129, 2.0172, 0.0}, /* BT.601 */
|
||||
{1.1643, 0.0, 1.7927, -0.2132, -0.5329, 2.1124, 0.0} /* BT.709 */
|
||||
};
|
||||
};
|
||||
|
||||
static void
|
||||
glamor_display_textured_video(glamor_port_private *port_priv)
|
||||
{
|
||||
ScreenPtr screen = port_priv->pPixmap->drawable.pScreen;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
ScreenPtr screen = port_priv->pPixmap->drawable.pScreen;
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(port_priv->pPixmap);
|
||||
glamor_pixmap_private *src_pixmap_priv[3];
|
||||
glamor_gl_dispatch *dispatch;
|
||||
float vertices[32], texcoords[8];
|
||||
BoxPtr box = REGION_RECTS(&port_priv->clip);
|
||||
int nBox = REGION_NUM_RECTS(&port_priv->clip);
|
||||
int dst_x_off, dst_y_off;
|
||||
GLfloat dst_xscale, dst_yscale;
|
||||
GLfloat src_xscale[3], src_yscale[3];
|
||||
int i;
|
||||
const float Loff = -0.0627;
|
||||
const float Coff = -0.502;
|
||||
float uvcosf, uvsinf;
|
||||
float yco;
|
||||
float uco[3], vco[3], off[3];
|
||||
float bright, cont, gamma;
|
||||
int ref = port_priv->transform_index;
|
||||
GLint uloc, sampler_loc;
|
||||
glamor_pixmap_private *src_pixmap_priv[3];
|
||||
glamor_gl_dispatch *dispatch;
|
||||
float vertices[32], texcoords[8];
|
||||
BoxPtr box = REGION_RECTS(&port_priv->clip);
|
||||
int nBox = REGION_NUM_RECTS(&port_priv->clip);
|
||||
int dst_x_off, dst_y_off;
|
||||
GLfloat dst_xscale, dst_yscale;
|
||||
GLfloat src_xscale[3], src_yscale[3];
|
||||
int i;
|
||||
const float Loff = -0.0627;
|
||||
const float Coff = -0.502;
|
||||
float uvcosf, uvsinf;
|
||||
float yco;
|
||||
float uco[3], vco[3], off[3];
|
||||
float bright, cont, gamma;
|
||||
int ref = port_priv->transform_index;
|
||||
GLint uloc, sampler_loc;
|
||||
|
||||
cont = RTFContrast(port_priv->contrast);
|
||||
bright = RTFBrightness(port_priv->brightness);
|
||||
gamma = (float)port_priv->gamma / 1000.0;
|
||||
uvcosf = RTFSaturation(port_priv->saturation) * cos(RTFHue(port_priv->hue));
|
||||
uvsinf = RTFSaturation(port_priv->saturation) * sin(RTFHue(port_priv->hue));
|
||||
cont = RTFContrast(port_priv->contrast);
|
||||
bright = RTFBrightness(port_priv->brightness);
|
||||
gamma = (float) port_priv->gamma / 1000.0;
|
||||
uvcosf = RTFSaturation(port_priv->saturation) * cos(RTFHue(port_priv->hue));
|
||||
uvsinf = RTFSaturation(port_priv->saturation) * sin(RTFHue(port_priv->hue));
|
||||
/* overlay video also does pre-gamma contrast/sat adjust, should we? */
|
||||
|
||||
yco = trans[ref].RefLuma * cont;
|
||||
uco[0] = -trans[ref].RefRCr * uvsinf;
|
||||
uco[1] = trans[ref].RefGCb * uvcosf - trans[ref].RefGCr * uvsinf;
|
||||
uco[2] = trans[ref].RefBCb * uvcosf;
|
||||
vco[0] = trans[ref].RefRCr * uvcosf;
|
||||
vco[1] = trans[ref].RefGCb * uvsinf + trans[ref].RefGCr * uvcosf;
|
||||
vco[2] = trans[ref].RefBCb * uvsinf;
|
||||
off[0] = Loff * yco + Coff * (uco[0] + vco[0]) + bright;
|
||||
off[1] = Loff * yco + Coff * (uco[1] + vco[1]) + bright;
|
||||
off[2] = Loff * yco + Coff * (uco[2] + vco[2]) + bright;
|
||||
gamma = 1.0;
|
||||
yco = trans[ref].RefLuma * cont;
|
||||
uco[0] = -trans[ref].RefRCr * uvsinf;
|
||||
uco[1] = trans[ref].RefGCb * uvcosf - trans[ref].RefGCr * uvsinf;
|
||||
uco[2] = trans[ref].RefBCb * uvcosf;
|
||||
vco[0] = trans[ref].RefRCr * uvcosf;
|
||||
vco[1] = trans[ref].RefGCb * uvsinf + trans[ref].RefGCr * uvcosf;
|
||||
vco[2] = trans[ref].RefBCb * uvsinf;
|
||||
off[0] = Loff * yco + Coff * (uco[0] + vco[0]) + bright;
|
||||
off[1] = Loff * yco + Coff * (uco[1] + vco[1]) + bright;
|
||||
off[2] = Loff * yco + Coff * (uco[2] + vco[2]) + bright;
|
||||
gamma = 1.0;
|
||||
|
||||
pixmap_priv_get_dest_scale(pixmap_priv, &dst_xscale, &dst_yscale);
|
||||
glamor_get_drawable_deltas(port_priv->pDraw, port_priv->pPixmap, &dst_x_off,
|
||||
pixmap_priv_get_dest_scale(pixmap_priv, &dst_xscale, &dst_yscale);
|
||||
glamor_get_drawable_deltas(port_priv->pDraw, port_priv->pPixmap, &dst_x_off,
|
||||
&dst_y_off);
|
||||
glamor_set_destination_pixmap_priv_nc(pixmap_priv);
|
||||
glamor_set_destination_pixmap_priv_nc(pixmap_priv);
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (port_priv->src_pix[i]) {
|
||||
src_pixmap_priv[i] = glamor_get_pixmap_private(port_priv->src_pix[i]);
|
||||
pixmap_priv_get_scale(src_pixmap_priv[i], &src_xscale[i], &src_yscale[i]);
|
||||
}
|
||||
}
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glUseProgram(glamor_priv->xv_prog);
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (port_priv->src_pix[i]) {
|
||||
src_pixmap_priv[i] =
|
||||
glamor_get_pixmap_private(port_priv->src_pix[i]);
|
||||
pixmap_priv_get_scale(src_pixmap_priv[i], &src_xscale[i],
|
||||
&src_yscale[i]);
|
||||
}
|
||||
}
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glUseProgram(glamor_priv->xv_prog);
|
||||
|
||||
uloc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "offsetyco");
|
||||
dispatch->glUniform4f(uloc, off[0], off[1], off[2], yco);
|
||||
uloc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "ucogamma");
|
||||
dispatch->glUniform4f(uloc, uco[0], uco[1], uco[2], gamma);
|
||||
uloc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "vco");
|
||||
dispatch->glUniform4f(uloc, vco[0], vco[1], vco[2], 0);
|
||||
uloc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "offsetyco");
|
||||
dispatch->glUniform4f(uloc, off[0], off[1], off[2], yco);
|
||||
uloc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "ucogamma");
|
||||
dispatch->glUniform4f(uloc, uco[0], uco[1], uco[2], gamma);
|
||||
uloc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "vco");
|
||||
dispatch->glUniform4f(uloc, vco[0], vco[1], vco[2], 0);
|
||||
|
||||
dispatch->glActiveTexture(GL_TEXTURE0);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[0]->base.fbo->tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MIN_FILTER,
|
||||
GL_LINEAR);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MAG_FILTER,
|
||||
GL_LINEAR);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_S,
|
||||
GL_CLAMP_TO_EDGE);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_T,
|
||||
GL_CLAMP_TO_EDGE);
|
||||
dispatch->glActiveTexture(GL_TEXTURE0);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[0]->base.fbo->tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
dispatch->glActiveTexture(GL_TEXTURE1);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[1]->base.fbo->tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MIN_FILTER,
|
||||
GL_LINEAR);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MAG_FILTER,
|
||||
GL_LINEAR);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_S,
|
||||
GL_CLAMP_TO_EDGE);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_T,
|
||||
GL_CLAMP_TO_EDGE);
|
||||
dispatch->glActiveTexture(GL_TEXTURE1);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[1]->base.fbo->tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
dispatch->glActiveTexture(GL_TEXTURE2);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[2]->base.fbo->tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MIN_FILTER,
|
||||
GL_LINEAR);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MAG_FILTER,
|
||||
GL_LINEAR);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_S,
|
||||
GL_CLAMP_TO_EDGE);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_T,
|
||||
GL_CLAMP_TO_EDGE);
|
||||
dispatch->glActiveTexture(GL_TEXTURE2);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[2]->base.fbo->tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
sampler_loc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "y_sampler");
|
||||
dispatch->glUniform1i(sampler_loc, 0);
|
||||
sampler_loc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "u_sampler");
|
||||
dispatch->glUniform1i(sampler_loc, 1);
|
||||
sampler_loc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "v_sampler");
|
||||
dispatch->glUniform1i(sampler_loc, 2);
|
||||
sampler_loc =
|
||||
dispatch->glGetUniformLocation(glamor_priv->xv_prog, "y_sampler");
|
||||
dispatch->glUniform1i(sampler_loc, 0);
|
||||
sampler_loc =
|
||||
dispatch->glGetUniformLocation(glamor_priv->xv_prog, "u_sampler");
|
||||
dispatch->glUniform1i(sampler_loc, 1);
|
||||
sampler_loc =
|
||||
dispatch->glGetUniformLocation(glamor_priv->xv_prog, "v_sampler");
|
||||
dispatch->glUniform1i(sampler_loc, 2);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
|
||||
GL_FLOAT, GL_FALSE,
|
||||
2 * sizeof(float),
|
||||
texcoords);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
2 * sizeof(float), texcoords);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
vertices);
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float), vertices);
|
||||
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
for (i = 0; i < nBox; i++) {
|
||||
float off_x = box[i].x1 - port_priv->drw_x;
|
||||
float off_y = box[i].y1 - port_priv->drw_y;
|
||||
float diff_x = (float)port_priv->src_w / (float)port_priv->dst_w;
|
||||
float diff_y = (float)port_priv->src_h / (float)port_priv->dst_h;
|
||||
float srcx, srcy, srcw, srch;
|
||||
int dstx, dsty, dstw, dsth;
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
for (i = 0; i < nBox; i++) {
|
||||
float off_x = box[i].x1 - port_priv->drw_x;
|
||||
float off_y = box[i].y1 - port_priv->drw_y;
|
||||
float diff_x = (float) port_priv->src_w / (float) port_priv->dst_w;
|
||||
float diff_y = (float) port_priv->src_h / (float) port_priv->dst_h;
|
||||
float srcx, srcy, srcw, srch;
|
||||
int dstx, dsty, dstw, dsth;
|
||||
|
||||
dstx = box[i].x1 + dst_x_off;
|
||||
dsty = box[i].y1 + dst_y_off;
|
||||
dstw = box[i].x2 - box[i].x1;
|
||||
dsth = box[i].y2 - box[i].y1;
|
||||
|
||||
dstx = box[i].x1 + dst_x_off;
|
||||
dsty = box[i].y1 + dst_y_off;
|
||||
dstw = box[i].x2 - box[i].x1;
|
||||
dsth = box[i].y2 - box[i].y1;
|
||||
srcx = port_priv->src_x + off_x * diff_x;
|
||||
srcy = port_priv->src_y + off_y * diff_y;
|
||||
srcw = (port_priv->src_w * dstw) / (float) port_priv->dst_w;
|
||||
srch = (port_priv->src_h * dsth) / (float) port_priv->dst_h;
|
||||
|
||||
srcx = port_priv->src_x + off_x * diff_x;
|
||||
srcy = port_priv->src_y + off_y * diff_y;
|
||||
srcw = (port_priv->src_w * dstw) / (float)port_priv->dst_w;
|
||||
srch = (port_priv->src_h * dsth) / (float)port_priv->dst_h;
|
||||
|
||||
glamor_set_normalize_vcoords(pixmap_priv,
|
||||
glamor_set_normalize_vcoords(pixmap_priv,
|
||||
dst_xscale, dst_yscale,
|
||||
dstx,
|
||||
dsty,
|
||||
dstx + dstw,
|
||||
dsty + dsth,
|
||||
glamor_priv->yInverted,
|
||||
vertices);
|
||||
glamor_priv->yInverted, vertices);
|
||||
|
||||
glamor_set_normalize_tcoords(src_pixmap_priv[0],
|
||||
glamor_set_normalize_tcoords(src_pixmap_priv[0],
|
||||
src_xscale[0],
|
||||
src_yscale[0],
|
||||
srcx,
|
||||
srcy,
|
||||
srcx + srcw,
|
||||
srcy + srch,
|
||||
glamor_priv->yInverted,
|
||||
texcoords);
|
||||
glamor_priv->yInverted, texcoords);
|
||||
|
||||
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
}
|
||||
|
||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
|
||||
dispatch->glUseProgram(0);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
DamageDamageRegion(port_priv->pDraw, &port_priv->clip);
|
||||
}
|
||||
|
||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
|
||||
dispatch->glUseProgram(0);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
DamageDamageRegion(port_priv->pDraw, &port_priv->clip);
|
||||
}
|
||||
|
||||
static int glamor_xv_put_image(ScrnInfoPtr pScrn,
|
||||
static int
|
||||
glamor_xv_put_image(ScrnInfoPtr pScrn,
|
||||
short src_x, short src_y,
|
||||
short drw_x, short drw_y,
|
||||
short src_w, short src_h,
|
||||
|
@ -455,12 +440,10 @@ static int glamor_xv_put_image(ScrnInfoPtr pScrn,
|
|||
short width,
|
||||
short height,
|
||||
Bool sync,
|
||||
RegionPtr clipBoxes,
|
||||
pointer data,
|
||||
DrawablePtr pDrawable)
|
||||
RegionPtr clipBoxes, void *data, DrawablePtr pDrawable)
|
||||
{
|
||||
ScreenPtr screen = xf86ScrnToScreen(pScrn);
|
||||
glamor_port_private *port_priv = (glamor_port_private *)data;
|
||||
glamor_port_private *port_priv = (glamor_port_private *) data;
|
||||
INT32 x1, x2, y1, y2;
|
||||
int srcPitch, srcPitch2;
|
||||
BoxRec dstBox;
|
||||
|
@ -479,7 +462,8 @@ static int glamor_xv_put_image(ScrnInfoPtr pScrn,
|
|||
dstBox.x2 = drw_x + drw_w;
|
||||
dstBox.y1 = drw_y;
|
||||
dstBox.y2 = drw_y + drw_h;
|
||||
if (!xf86XVClipVideoHelper(&dstBox, &x1, &x2, &y1, &y2, clipBoxes, width, height))
|
||||
if (!xf86XVClipVideoHelper
|
||||
(&dstBox, &x1, &x2, &y1, &y2, clipBoxes, width, height))
|
||||
return Success;
|
||||
|
||||
if ((x1 >= x2) || (y1 >= y2))
|
||||
|
@ -488,19 +472,25 @@ static int glamor_xv_put_image(ScrnInfoPtr pScrn,
|
|||
srcPitch = width;
|
||||
srcPitch2 = width >> 1;
|
||||
|
||||
if (!port_priv->src_pix[0] || (width != port_priv->src_pix_w || height != port_priv->src_pix_h)) {
|
||||
if (!port_priv->src_pix[0] ||
|
||||
(width != port_priv->src_pix_w || height != port_priv->src_pix_h)) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
if (port_priv->src_pix[i])
|
||||
glamor_destroy_pixmap(port_priv->src_pix[i]);
|
||||
|
||||
port_priv->src_pix[0] = glamor_create_pixmap(screen, width, height, 8, 0);
|
||||
port_priv->src_pix[1] = glamor_create_pixmap(screen, width >> 1, height >> 1, 8, 0);
|
||||
port_priv->src_pix[2] = glamor_create_pixmap(screen, width >> 1, height >> 1, 8, 0);
|
||||
port_priv->src_pix[0] =
|
||||
glamor_create_pixmap(screen, width, height, 8, 0);
|
||||
port_priv->src_pix[1] =
|
||||
glamor_create_pixmap(screen, width >> 1, height >> 1, 8, 0);
|
||||
port_priv->src_pix[2] =
|
||||
glamor_create_pixmap(screen, width >> 1, height >> 1, 8, 0);
|
||||
port_priv->src_pix_w = width;
|
||||
port_priv->src_pix_h = height;
|
||||
|
||||
if (!port_priv->src_pix[0] || !port_priv->src_pix[1] || !port_priv->src_pix[2])
|
||||
if (!port_priv->src_pix[0] || !port_priv->src_pix[1] ||
|
||||
!port_priv->src_pix[2])
|
||||
return BadAlloc;
|
||||
}
|
||||
|
||||
|
@ -539,9 +529,9 @@ static int glamor_xv_put_image(ScrnInfoPtr pScrn,
|
|||
}
|
||||
|
||||
if (pDrawable->type == DRAWABLE_WINDOW)
|
||||
port_priv->pPixmap = (*screen->GetWindowPixmap)((WindowPtr)pDrawable);
|
||||
port_priv->pPixmap = (*screen->GetWindowPixmap) ((WindowPtr) pDrawable);
|
||||
else
|
||||
port_priv->pPixmap = (PixmapPtr)pDrawable;
|
||||
port_priv->pPixmap = (PixmapPtr) pDrawable;
|
||||
|
||||
if (!RegionEqual(&port_priv->clip, clipBoxes)) {
|
||||
RegionCopy(&port_priv->clip, clipBoxes);
|
||||
|
@ -562,8 +552,7 @@ static int glamor_xv_put_image(ScrnInfoPtr pScrn,
|
|||
return Success;
|
||||
}
|
||||
|
||||
static XF86VideoEncodingRec DummyEncodingGLAMOR[1] =
|
||||
{
|
||||
static XF86VideoEncodingRec DummyEncodingGLAMOR[1] = {
|
||||
{
|
||||
0,
|
||||
"XV_IMAGE",
|
||||
|
@ -600,12 +589,13 @@ glamor_xv_init(ScreenPtr screen, int num_texture_ports)
|
|||
adapt->nFormats = NUM_FORMATS;
|
||||
adapt->pFormats = Formats;
|
||||
adapt->nPorts = num_texture_ports;
|
||||
adapt->pPortPrivates = (DevUnion*)(&adapt[1]);
|
||||
adapt->pPortPrivates = (DevUnion *) (&adapt[1]);
|
||||
|
||||
adapt->pAttributes = Attributes_glamor;
|
||||
adapt->nAttributes = NUM_ATTRIBUTES;
|
||||
|
||||
port_priv = (glamor_port_private *)(&adapt->pPortPrivates[num_texture_ports]);
|
||||
port_priv =
|
||||
(glamor_port_private *) (&adapt->pPortPrivates[num_texture_ports]);
|
||||
adapt->pImages = Images;
|
||||
adapt->nImages = NUM_IMAGES;
|
||||
adapt->PutVideo = NULL;
|
||||
|
@ -632,14 +622,16 @@ glamor_xv_init(ScreenPtr screen, int num_texture_ports)
|
|||
|
||||
REGION_NULL(pScreen, &pPriv->clip);
|
||||
|
||||
adapt->pPortPrivates[i].ptr = (pointer)(pPriv);
|
||||
adapt->pPortPrivates[i].ptr = (void *) (pPriv);
|
||||
}
|
||||
return adapt;
|
||||
}
|
||||
#else
|
||||
#if 0
|
||||
XF86VideoAdaptorPtr
|
||||
glamor_xv_init(ScreenPtr screen, int num_texture_ports)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
121
glamor/glapi.h
121
glamor/glapi.h
|
@ -1,121 +0,0 @@
|
|||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 7.1
|
||||
*
|
||||
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \mainpage Mesa GL API Module
|
||||
*
|
||||
* \section GLAPIIntroduction Introduction
|
||||
*
|
||||
* The Mesa GL API module is responsible for dispatching all the
|
||||
* gl*() functions. All GL functions are dispatched by jumping through
|
||||
* the current dispatch table (basically a struct full of function
|
||||
* pointers.)
|
||||
*
|
||||
* A per-thread current dispatch table and per-thread current context
|
||||
* pointer are managed by this module too.
|
||||
*
|
||||
* This module is intended to be non-Mesa-specific so it can be used
|
||||
* with the X/DRI libGL also.
|
||||
*/
|
||||
|
||||
#ifndef _GLAPI_H
|
||||
#define _GLAPI_H
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
|
||||
#if GLAMOR_GLES2
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#include "GL/glext.h"
|
||||
#endif
|
||||
|
||||
/* Is this needed? It is incomplete anyway. */
|
||||
#ifdef USE_MGL_NAMESPACE
|
||||
#define _glapi_set_dispatch _mglapi_set_dispatch
|
||||
#define _glapi_get_dispatch _mglapi_get_dispatch
|
||||
#define _glapi_set_context _mglapi_set_context
|
||||
#define _glapi_get_context _mglapi_get_context
|
||||
#define _glapi_Dispatch _mglapi_Dispatch
|
||||
#define _glapi_Context _mglapi_Context
|
||||
#endif
|
||||
|
||||
typedef void (*_glapi_proc)(void);
|
||||
struct _glapi_table;
|
||||
|
||||
|
||||
#if defined (GLX_USE_TLS)
|
||||
|
||||
extern __thread struct _glapi_table * _glapi_tls_Dispatch
|
||||
__attribute__((tls_model("initial-exec")));
|
||||
|
||||
extern __thread void * _glapi_tls_Context
|
||||
__attribute__((tls_model("initial-exec")));
|
||||
|
||||
extern const struct _glapi_table *_glapi_Dispatch;
|
||||
extern const void *_glapi_Context;
|
||||
|
||||
# define GET_DISPATCH() _glapi_tls_Dispatch
|
||||
# define GET_CURRENT_CONTEXT(C) C = (typeof(C)) _glapi_tls_Context
|
||||
# define SET_CURRENT_CONTEXT(C) _glapi_tls_Context = (void*)C
|
||||
|
||||
#else
|
||||
|
||||
extern struct _glapi_table *_glapi_Dispatch;
|
||||
extern void *_glapi_Context;
|
||||
|
||||
# ifdef THREADS
|
||||
|
||||
# define GET_DISPATCH() \
|
||||
(likely(_glapi_Dispatch) ? _glapi_Dispatch : _glapi_get_dispatch())
|
||||
|
||||
# define GET_CURRENT_CONTEXT(C) C = (typeof(C)) \
|
||||
(likely(_glapi_Context) ? _glapi_Context : _glapi_get_context())
|
||||
|
||||
|
||||
# define SET_CURRENT_CONTEXT(C) do { if (likely(_glapi_Context)) \
|
||||
_glapi_Context = (void*)C; \
|
||||
else \
|
||||
_glapi_set_context(C); } while(0)
|
||||
|
||||
# else
|
||||
|
||||
# define GET_DISPATCH() _glapi_Dispatch
|
||||
# define GET_CURRENT_CONTEXT(C) C = (typeof(C)) _glapi_Context
|
||||
# define SET_CURRENT_CONTEXT(C) _glapi_Context = (void*)C
|
||||
|
||||
# endif
|
||||
|
||||
#endif /* defined (GLX_USE_TLS) */
|
||||
|
||||
|
||||
extern void
|
||||
_glapi_set_context(void *context);
|
||||
|
||||
extern void *
|
||||
_glapi_get_context(void);
|
||||
|
||||
#endif
|
|
@ -478,4 +478,7 @@
|
|||
/* Ask fontsproto to make font path element names const */
|
||||
#define FONT_PATH_ELEMENT_NAME_CONST 1
|
||||
|
||||
/* Build GLAMOR */
|
||||
#undef GLAMOR
|
||||
|
||||
#endif /* _DIX_CONFIG_H_ */
|
||||
|
|
Loading…
Reference in New Issue