glamor: Merged with latest xserver.
Merged with latest xserver, the major change is due to the API change of the management of devPrivates.
This commit is contained in:
parent
3105fe9f64
commit
b3577a1c85
|
@ -30,17 +30,13 @@
|
|||
* functions not responsible for performing rendering.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "glamor_priv.h"
|
||||
|
||||
static int glamor_screen_private_key_index;
|
||||
static DevPrivateKeyRec glamor_screen_private_key_index;
|
||||
DevPrivateKey glamor_screen_private_key = &glamor_screen_private_key_index;
|
||||
static int glamor_pixmap_private_key_index;
|
||||
static DevPrivateKeyRec glamor_pixmap_private_key_index;
|
||||
DevPrivateKey glamor_pixmap_private_key = &glamor_pixmap_private_key_index;
|
||||
|
||||
/**
|
||||
|
@ -68,54 +64,59 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
|||
unsigned int usage)
|
||||
{
|
||||
PixmapPtr pixmap;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_pixmap_private *pixmap_priv, *newpixmap_priv;
|
||||
GLenum format;
|
||||
|
||||
if (w > 32767 || h > 32767)
|
||||
return NullPixmap;
|
||||
|
||||
pixmap = fbCreatePixmap (screen, 0, 0, depth, usage);
|
||||
if (dixAllocatePrivates(pixmap->devPrivates, PRIVATE_PIXMAP) != TRUE) {
|
||||
fbDestroyPixmap(pixmap);
|
||||
ErrorF("Fail to allocate privates for PIXMAP.\n");
|
||||
return NullPixmap;
|
||||
}
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
assert(pixmap_priv != NULL);
|
||||
|
||||
if (w == 0 || h == 0)
|
||||
return pixmap;
|
||||
|
||||
/* We should probably take advantage of ARB_fbo's allowance of GL_ALPHA.
|
||||
* FBOs, which EXT_fbo forgot to do.
|
||||
*/
|
||||
switch (depth) {
|
||||
case 24:
|
||||
format = GL_RGB;
|
||||
break;
|
||||
format = GL_RGB;
|
||||
break;
|
||||
default:
|
||||
format = GL_RGBA;
|
||||
break;
|
||||
format = GL_RGBA;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Create the texture used to store the pixmap's data. */
|
||||
glGenTextures(1, &pixmap_priv->tex);
|
||||
glBindTexture(GL_TEXTURE_2D, pixmap_priv->tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0,
|
||||
format, GL_UNSIGNED_BYTE, NULL);
|
||||
format, GL_UNSIGNED_BYTE, NULL);
|
||||
|
||||
/* Create a framebuffer object wrapping the texture so that we can render
|
||||
* to it.
|
||||
*/
|
||||
/* Create a framebuffer object wrapping the texture so that we can render
|
||||
** to it.
|
||||
**/
|
||||
glGenFramebuffersEXT(1, &pixmap_priv->fb);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, pixmap_priv->fb);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
|
||||
GL_COLOR_ATTACHMENT0_EXT,
|
||||
GL_TEXTURE_2D,
|
||||
pixmap_priv->tex,
|
||||
0);
|
||||
GL_COLOR_ATTACHMENT0_EXT,
|
||||
GL_TEXTURE_2D,
|
||||
pixmap_priv->tex,
|
||||
0);
|
||||
|
||||
screen->ModifyPixmapHeader(pixmap, w, h, 0, 0,
|
||||
screen->ModifyPixmapHeader(pixmap, w, h, depth, 0,
|
||||
(((w * pixmap->drawable.bitsPerPixel +
|
||||
7) / 8) + 3) & ~3,
|
||||
NULL);
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
|
@ -156,13 +157,22 @@ glamor_init(ScreenPtr screen)
|
|||
if (glamor_priv == NULL)
|
||||
return FALSE;
|
||||
|
||||
dixSetPrivate(&screen->devPrivates, glamor_screen_private_key, glamor_priv);
|
||||
if (!dixRequestPrivate(glamor_pixmap_private_key,
|
||||
sizeof(glamor_pixmap_private))) {
|
||||
|
||||
if (!dixRegisterPrivateKey(glamor_screen_private_key,PRIVATE_SCREEN,
|
||||
0)) {
|
||||
LogMessage(X_WARNING,
|
||||
"glamor%d: Failed to allocate pixmap private\n",
|
||||
"glamor%d: Failed to allocate screen private\n",
|
||||
screen->myNum);
|
||||
}
|
||||
dixSetPrivate(&screen->devPrivates, glamor_screen_private_key, glamor_priv);
|
||||
|
||||
if (!dixRegisterPrivateKey(glamor_pixmap_private_key,PRIVATE_PIXMAP,
|
||||
sizeof(glamor_pixmap_private))) {
|
||||
LogMessage(X_WARNING,
|
||||
"glamor%d: Failed to allocate pixmap private\n",
|
||||
screen->myNum);
|
||||
}
|
||||
|
||||
|
||||
glewInit();
|
||||
|
||||
|
@ -224,16 +234,15 @@ glamor_init(ScreenPtr screen)
|
|||
ps->Trapezoids = glamor_trapezoids;
|
||||
glamor_priv->saved_glyphs = ps->Glyphs;
|
||||
ps->Glyphs = glamor_glyphs;
|
||||
glamor_init_composite_shaders(screen);
|
||||
#endif
|
||||
|
||||
glamor_init_solid_shader(screen);
|
||||
glamor_init_tile_shader(screen);
|
||||
glamor_init_putimage_shaders(screen);
|
||||
glamor_init_composite_shaders(screen);
|
||||
glamor_init_finish_access_shaders(screen);
|
||||
|
||||
glamor_glyphs_init(screen);
|
||||
|
||||
|
||||
return TRUE;
|
||||
|
||||
fail:
|
||||
|
|
Loading…
Reference in New Issue
Block a user