glamor_set_pixmap_texture/screen_pixmap: Remove useless parameters.
As after we got a texture, no matter the texture is created on the glamor_create_pixmap or on the egl layer, we all already know the texture's width and height there. We don't need to pass them in. This commit also simply the glamor_egl_create_textured_screen to reuse the egl_create_textured_pixmap. And also remove the useless root image from the egl private structure. As now the root image is bound to the screen image, we don't take care it separately here. It will be freed at the screen closing. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
This commit is contained in:
parent
15166bba97
commit
ca2ddd33a1
|
@ -78,17 +78,18 @@ glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type)
|
||||||
pixmap_priv->type = type;
|
pixmap_priv->type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_X_EXPORT void
|
_X_EXPORT void
|
||||||
glamor_set_pixmap_texture(PixmapPtr pixmap, int w, int h, unsigned int tex)
|
glamor_set_pixmap_texture(PixmapPtr pixmap, unsigned int tex)
|
||||||
{
|
{
|
||||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||||
glamor_pixmap_private *pixmap_priv;
|
glamor_pixmap_private *pixmap_priv;
|
||||||
glamor_screen_private *glamor_priv =
|
glamor_screen_private *glamor_priv;
|
||||||
glamor_get_screen_private(screen);
|
glamor_gl_dispatch *dispatch;
|
||||||
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
|
|
||||||
|
|
||||||
|
glamor_priv = glamor_get_screen_private(screen);
|
||||||
|
dispatch = &glamor_priv->dispatch;
|
||||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||||
|
|
||||||
if (pixmap_priv == NULL) {
|
if (pixmap_priv == NULL) {
|
||||||
pixmap_priv = calloc(sizeof(*pixmap_priv), 1);
|
pixmap_priv = calloc(sizeof(*pixmap_priv), 1);
|
||||||
dixSetPrivate(&pixmap->devPrivates,
|
dixSetPrivate(&pixmap->devPrivates,
|
||||||
|
@ -117,27 +118,18 @@ glamor_set_pixmap_texture(PixmapPtr pixmap, int w, int h, unsigned int tex)
|
||||||
pixmap_priv->gl_tex = 0;
|
pixmap_priv->gl_tex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pixmap->devKind == 0)
|
|
||||||
screen->ModifyPixmapHeader(pixmap, w, h, 0, 0,
|
|
||||||
(((w *
|
|
||||||
pixmap->drawable.
|
|
||||||
bitsPerPixel + 7) / 8) +
|
|
||||||
3) & ~3, NULL);
|
|
||||||
pixmap->devPrivate.ptr = NULL;
|
pixmap->devPrivate.ptr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set screen pixmap. If tex equal to 0, means it is called from ephyr. */
|
|
||||||
void
|
void
|
||||||
glamor_set_screen_pixmap_texture(ScreenPtr screen, int w, int h,
|
glamor_set_screen_pixmap(PixmapPtr screen_pixmap)
|
||||||
unsigned int tex)
|
|
||||||
{
|
{
|
||||||
PixmapPtr pixmap = screen->GetScreenPixmap(screen);
|
ScreenPtr screen = screen_pixmap->drawable.pScreen;
|
||||||
glamor_pixmap_private *pixmap_priv;
|
glamor_pixmap_private *pixmap_priv;
|
||||||
glamor_screen_private *glamor_priv =
|
glamor_screen_private *glamor_priv;
|
||||||
glamor_get_screen_private(screen);
|
|
||||||
|
|
||||||
glamor_set_pixmap_texture(pixmap, w, h, tex);
|
glamor_priv = glamor_get_screen_private(screen);
|
||||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
pixmap_priv = glamor_get_pixmap_private(screen_pixmap);
|
||||||
glamor_priv->screen_fbo = pixmap_priv->fb;
|
glamor_priv->screen_fbo = pixmap_priv->fb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +179,13 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
||||||
dispatch->glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0, format,
|
dispatch->glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0, format,
|
||||||
GL_UNSIGNED_BYTE, NULL);
|
GL_UNSIGNED_BYTE, NULL);
|
||||||
|
|
||||||
glamor_set_pixmap_texture(pixmap, w, h, tex);
|
glamor_set_pixmap_texture(pixmap, tex);
|
||||||
|
|
||||||
|
screen->ModifyPixmapHeader(pixmap, w, h, 0, 0,
|
||||||
|
(((w *
|
||||||
|
pixmap->drawable.
|
||||||
|
bitsPerPixel + 7) / 8) +
|
||||||
|
3) & ~3, NULL);
|
||||||
|
|
||||||
return pixmap;
|
return pixmap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,9 +102,12 @@ typedef enum glamor_pixmap_type {
|
||||||
*/
|
*/
|
||||||
extern _X_EXPORT Bool glamor_init(ScreenPtr screen, unsigned int flags);
|
extern _X_EXPORT Bool glamor_init(ScreenPtr screen, unsigned int flags);
|
||||||
extern _X_EXPORT void glamor_fini(ScreenPtr screen);
|
extern _X_EXPORT void glamor_fini(ScreenPtr screen);
|
||||||
extern _X_EXPORT void glamor_set_screen_pixmap_texture(ScreenPtr screen,
|
|
||||||
int w, int h,
|
/* Let glamor to know the screen's fbo. The low level
|
||||||
unsigned int tex);
|
* 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);
|
||||||
|
|
||||||
/* @glamor_glyphs_init: Initialize glyphs internal data structures.
|
/* @glamor_glyphs_init: Initialize glyphs internal data structures.
|
||||||
*
|
*
|
||||||
* @pScreen: Current screen pointer.
|
* @pScreen: Current screen pointer.
|
||||||
|
@ -115,7 +118,7 @@ extern _X_EXPORT void glamor_set_screen_pixmap_texture(ScreenPtr screen,
|
||||||
*/
|
*/
|
||||||
extern _X_EXPORT Bool glamor_glyphs_init(ScreenPtr pScreen);
|
extern _X_EXPORT Bool glamor_glyphs_init(ScreenPtr pScreen);
|
||||||
|
|
||||||
extern _X_EXPORT void glamor_set_pixmap_texture(PixmapPtr pixmap, int w, int h,
|
extern _X_EXPORT void glamor_set_pixmap_texture(PixmapPtr pixmap,
|
||||||
unsigned int tex);
|
unsigned int tex);
|
||||||
|
|
||||||
extern _X_EXPORT void glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type);
|
extern _X_EXPORT void glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type);
|
||||||
|
|
|
@ -59,10 +59,6 @@
|
||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
#include <EGL/eglext.h>
|
#include <EGL/eglext.h>
|
||||||
|
|
||||||
#define GLAMOR_VERSION_MAJOR 0
|
|
||||||
#define GLAMOR_VERSION_MINOR 1
|
|
||||||
#define GLAMOR_VERSION_PATCH 0
|
|
||||||
|
|
||||||
#include "glamor.h"
|
#include "glamor.h"
|
||||||
#include "glamor_gl_dispatch.h"
|
#include "glamor_gl_dispatch.h"
|
||||||
|
|
||||||
|
@ -169,40 +165,22 @@ glamor_create_texture_from_image(struct glamor_egl_screen_private
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
glamor_egl_create_textured_screen(ScreenPtr screen, int handle, int stride)
|
glamor_egl_create_textured_screen(ScreenPtr screen, int handle, int stride)
|
||||||
{
|
{
|
||||||
ScrnInfoPtr scrn = xf86Screens[screen->myNum];
|
ScrnInfoPtr scrn = xf86Screens[screen->myNum];
|
||||||
struct glamor_egl_screen_private *glamor_egl =
|
struct glamor_egl_screen_private *glamor_egl;
|
||||||
glamor_egl_get_screen_private(scrn);
|
PixmapPtr screen_pixmap;
|
||||||
EGLImageKHR image;
|
|
||||||
GLuint texture;
|
|
||||||
|
|
||||||
if (!glamor_get_flink_name
|
glamor_egl = glamor_egl_get_screen_private(scrn);
|
||||||
(glamor_egl->fd, handle, &glamor_egl->front_buffer_handle)) {
|
screen_pixmap = screen->GetScreenPixmap(screen);
|
||||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
|
||||||
"Couldn't flink front buffer handle\n");
|
if (!glamor_egl_create_textured_pixmap(screen_pixmap, handle, stride)) {
|
||||||
|
xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to create textured screen.");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (glamor_egl->root) {
|
glamor_set_screen_pixmap(screen_pixmap);
|
||||||
eglDestroyImageKHR(glamor_egl->display, glamor_egl->root);
|
|
||||||
glamor_egl->root = EGL_NO_IMAGE_KHR;
|
|
||||||
}
|
|
||||||
|
|
||||||
image = _glamor_egl_create_image(glamor_egl,
|
|
||||||
scrn->virtualX,
|
|
||||||
scrn->virtualY,
|
|
||||||
stride / 4,
|
|
||||||
glamor_egl->front_buffer_handle, 32);
|
|
||||||
if (image == EGL_NO_IMAGE_KHR)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
glamor_create_texture_from_image(glamor_egl, image, &texture);
|
|
||||||
glamor_set_screen_pixmap_texture(screen, scrn->virtualX,
|
|
||||||
scrn->virtualY, texture);
|
|
||||||
glamor_egl->root = image;
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,12 +189,13 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
|
||||||
{
|
{
|
||||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||||
ScrnInfoPtr scrn = xf86Screens[screen->myNum];
|
ScrnInfoPtr scrn = xf86Screens[screen->myNum];
|
||||||
struct glamor_egl_screen_private *glamor_egl =
|
struct glamor_egl_screen_private *glamor_egl;
|
||||||
glamor_egl_get_screen_private(scrn);
|
|
||||||
EGLImageKHR image;
|
EGLImageKHR image;
|
||||||
GLuint texture;
|
GLuint texture;
|
||||||
int name;
|
int name;
|
||||||
|
|
||||||
|
glamor_egl = glamor_egl_get_screen_private(scrn);
|
||||||
|
|
||||||
if (!glamor_get_flink_name(glamor_egl->fd, handle, &name)) {
|
if (!glamor_get_flink_name(glamor_egl->fd, handle, &name)) {
|
||||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||||
"Couldn't flink pixmap handle\n");
|
"Couldn't flink pixmap handle\n");
|
||||||
|
@ -234,8 +213,7 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
|
||||||
|
|
||||||
glamor_create_texture_from_image(glamor_egl, image, &texture);
|
glamor_create_texture_from_image(glamor_egl, image, &texture);
|
||||||
glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
|
glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
|
||||||
glamor_set_pixmap_texture(pixmap, pixmap->drawable.width,
|
glamor_set_pixmap_texture(pixmap, texture);
|
||||||
pixmap->drawable.height, texture);
|
|
||||||
dixSetPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key,
|
dixSetPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key,
|
||||||
image);
|
image);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue