Commit ca2ddd33 authored by Zhigang Gong's avatar Zhigang Gong Committed by Eric Anholt

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: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
parent 15166bba
......@@ -78,17 +78,18 @@ glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type)
pixmap_priv->type = type;
}
_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;
glamor_pixmap_private *pixmap_priv;
glamor_screen_private *glamor_priv =
glamor_get_screen_private(screen);
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
glamor_screen_private *glamor_priv;
glamor_gl_dispatch *dispatch;
glamor_priv = glamor_get_screen_private(screen);
dispatch = &glamor_priv->dispatch;
pixmap_priv = glamor_get_pixmap_private(pixmap);
if (pixmap_priv == NULL) {
pixmap_priv = calloc(sizeof(*pixmap_priv), 1);
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;
}
if (pixmap->devKind == 0)
screen->ModifyPixmapHeader(pixmap, w, h, 0, 0,
(((w *
pixmap->drawable.
bitsPerPixel + 7) / 8) +
3) & ~3, NULL);
pixmap->devPrivate.ptr = NULL;
}
/* Set screen pixmap. If tex equal to 0, means it is called from ephyr. */
void
glamor_set_screen_pixmap_texture(ScreenPtr screen, int w, int h,
unsigned int tex)
glamor_set_screen_pixmap(PixmapPtr screen_pixmap)
{
PixmapPtr pixmap = screen->GetScreenPixmap(screen);
ScreenPtr screen = screen_pixmap->drawable.pScreen;
glamor_pixmap_private *pixmap_priv;
glamor_screen_private *glamor_priv =
glamor_get_screen_private(screen);
glamor_screen_private *glamor_priv;
glamor_set_pixmap_texture(pixmap, w, h, tex);
pixmap_priv = glamor_get_pixmap_private(pixmap);
glamor_priv = glamor_get_screen_private(screen);
pixmap_priv = glamor_get_pixmap_private(screen_pixmap);
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,
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;
}
......
......@@ -102,9 +102,12 @@ typedef enum glamor_pixmap_type {
*/
extern _X_EXPORT Bool glamor_init(ScreenPtr screen, unsigned int flags);
extern _X_EXPORT void glamor_fini(ScreenPtr screen);
extern _X_EXPORT void glamor_set_screen_pixmap_texture(ScreenPtr screen,
int w, int h,
unsigned int tex);
/* 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);
/* @glamor_glyphs_init: Initialize glyphs internal data structures.
*
* @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 void glamor_set_pixmap_texture(PixmapPtr pixmap, int w, int h,
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);
......
......@@ -59,10 +59,6 @@
#include <EGL/egl.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_gl_dispatch.h"
......@@ -169,40 +165,22 @@ glamor_create_texture_from_image(struct glamor_egl_screen_private
return TRUE;
}
Bool
glamor_egl_create_textured_screen(ScreenPtr screen, int handle, int stride)
{
ScrnInfoPtr scrn = xf86Screens[screen->myNum];
struct glamor_egl_screen_private *glamor_egl =
glamor_egl_get_screen_private(scrn);
EGLImageKHR image;
GLuint texture;
if (!glamor_get_flink_name
(glamor_egl->fd, handle, &glamor_egl->front_buffer_handle)) {
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
"Couldn't flink front buffer handle\n");
return FALSE;
}
struct glamor_egl_screen_private *glamor_egl;
PixmapPtr screen_pixmap;
if (glamor_egl->root) {
eglDestroyImageKHR(glamor_egl->display, glamor_egl->root);
glamor_egl->root = EGL_NO_IMAGE_KHR;
}
glamor_egl = glamor_egl_get_screen_private(scrn);
screen_pixmap = screen->GetScreenPixmap(screen);
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)
if (!glamor_egl_create_textured_pixmap(screen_pixmap, handle, stride)) {
xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to create textured screen.");
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;
glamor_set_screen_pixmap(screen_pixmap);
return TRUE;
}
......@@ -211,12 +189,13 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
{
ScreenPtr screen = pixmap->drawable.pScreen;
ScrnInfoPtr scrn = xf86Screens[screen->myNum];
struct glamor_egl_screen_private *glamor_egl =
glamor_egl_get_screen_private(scrn);
struct glamor_egl_screen_private *glamor_egl;
EGLImageKHR image;
GLuint texture;
int name;
glamor_egl = glamor_egl_get_screen_private(scrn);
if (!glamor_get_flink_name(glamor_egl->fd, handle, &name)) {
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
"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_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
glamor_set_pixmap_texture(pixmap, pixmap->drawable.width,
pixmap->drawable.height, texture);
glamor_set_pixmap_texture(pixmap, texture);
dixSetPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key,
image);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment