diff options
Diffstat (limited to 'glamor/glamor.c')
-rw-r--r-- | glamor/glamor.c | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/glamor/glamor.c b/glamor/glamor.c index b7259afa4..4b76b01d7 100644 --- a/glamor/glamor.c +++ b/glamor/glamor.c @@ -63,19 +63,45 @@ glamor_get_drawable_pixmap(DrawablePtr drawable) return (PixmapPtr)drawable; } +void +glamor_set_pixmap_texture(PixmapPtr pixmap, int w, int h, unsigned int tex) +{ + ScreenPtr screen = pixmap->drawable.pScreen; + glamor_pixmap_private *pixmap_priv; + + pixmap_priv = glamor_get_pixmap_private(pixmap); + pixmap_priv->tex = tex; + + /* 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); + + screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, + (((w * pixmap->drawable.bitsPerPixel + + 7) / 8) + 3) & ~3, + NULL); +} + static PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth, unsigned int usage) { PixmapPtr pixmap; - glamor_pixmap_private *pixmap_priv; + GLuint tex; GLenum format; if (w > 32767 || h > 32767) return NullPixmap; pixmap = fbCreatePixmap (screen, 0, 0, depth, usage); - pixmap_priv = glamor_get_pixmap_private(pixmap); + glamor_get_pixmap_private(pixmap); if (w == 0 || h == 0) return pixmap; @@ -93,28 +119,14 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth, } /* Create the texture used to store the pixmap's data. */ - glGenTextures(1, &pixmap_priv->tex); - glBindTexture(GL_TEXTURE_2D, pixmap_priv->tex); + glGenTextures(1, &tex); + glBindTexture(GL_TEXTURE_2D, 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); - /* 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); - - screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, - (((w * pixmap->drawable.bitsPerPixel + - 7) / 8) + 3) & ~3, - NULL); + glamor_set_pixmap_texture(pixmap, w, h, tex); return pixmap; } |