glamor-for-ddx: Exports all rendering/drawing functions.

This commit exports all the rest rendering/drawing functions
to the DDX drivers. And introduce some new pixmap type. For
a pixmap which has a separated texture, we never fallback
it to the DDX layer.

This commit also adds the following new functions:
glamor_composite_rects, glamor_get_image_nf which are needed
by UXA framework. Just a simple wrapper function of miXXX.
Will consider to optimize them next few weeks.

This commit also Fixed a glyphs rendering bug pointed by Chris.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
This commit is contained in:
Zhigang Gong 2011-12-13 22:48:34 +08:00 committed by Eric Anholt
parent f7539d9bff
commit 8c7fcefb96
19 changed files with 488 additions and 80 deletions

View File

@ -34,11 +34,13 @@ libglamor_la_SOURCES = \
glamor_setspans.c \
glamor_render.c \
glamor_tile.c \
glamor_triangles.c\
glamor_pixmap.c\
glamor_picture.c\
glamor_triangles.c\
glamor_addtraps.c\
glamor_getimage.c\
glamor_pixmap.c\
glamor_picture.c\
glamor_window.c\
glamor_gl_dispatch.c\
glamor_gl_dispatch.c\
glamor.h
sdk_HEADERS = glamor.h

View File

@ -374,7 +374,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
screen->GetSpans = glamor_get_spans;
glamor_priv->saved_get_image = screen->GetImage;
screen->GetImage = miGetImage;
screen->GetImage = glamor_get_image;
glamor_priv->saved_change_window_attributes =
screen->ChangeWindowAttributes;
@ -402,6 +402,9 @@ glamor_init(ScreenPtr screen, unsigned int flags)
glamor_priv->saved_triangles = ps->Triangles;
ps->Triangles = glamor_triangles;
glamor_priv->saved_addtraps = ps->AddTraps;
ps->AddTraps = glamor_add_traps;
glamor_priv->saved_unrealize_glyph = ps->UnrealizeGlyph;
ps->UnrealizeGlyph = glamor_glyph_unrealize;
}

View File

@ -41,9 +41,30 @@
#endif /* GLAMOR_H */
/* @GLAMOR_INVERTED_Y_AXIS:
* set 1 means the GL env's origin (0,0) is at top-left.
* EGL/DRM platform is an example need to set this bit.
* glx platform's origin is at bottom-left thus need to
* clear this bit.*/
#define GLAMOR_INVERTED_Y_AXIS 1
/* @GLAMOR_USE_SCREEN:
* If want to let glamor to do everything including the
* create/destroy pixmap and handle the gc ops. need to
* set this bit. Standalone glamor DDX driver need to set
* this bit.
* Otherwise, need to clear this bit, as the intel video
* driver with glamor enabled.
* */
#define GLAMOR_USE_SCREEN 2
/* @GLAMOR_USE_PICTURE_SCREEN:
* If want to let glamor to do all the composition related
* things, need to set this bit. Just as standalone glamor
* DDX driver.
* Otherwise, need to clear this bit, as the intel video
* driver with glamor enabled.
*/
#define GLAMOR_USE_PICTURE_SCREEN 4
#define GLAMOR_VALID_FLAGS (GLAMOR_INVERTED_Y_AXIS \
@ -54,12 +75,16 @@
* glamor_pixmap_type : glamor pixmap's type.
* @MEMORY: pixmap is in memory.
* @TEXTURE_DRM: pixmap is in a texture created from a DRM buffer.
* @SEPARATE_TEXTURE: The texture is created from a DRM buffer, but
* the format is incompatible, so this type of pixmap
* will never fallback to DDX layer.
* @DRM_ONLY: pixmap is in a external DRM buffer.
* @TEXTURE_ONLY: pixmap is in an internal texture.
*/
typedef enum glamor_pixmap_type {
GLAMOR_MEMORY,
GLAMOR_TEXTURE_DRM,
GLAMOR_SEPARATE_TEXTURE,
GLAMOR_DRM_ONLY,
GLAMOR_TEXTURE_ONLY
} glamor_pixmap_type_t;
@ -96,6 +121,11 @@ extern _X_EXPORT Bool glamor_egl_init_textured_pixmap(ScreenPtr screen);
extern _X_EXPORT void glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap);
#endif
/* 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
* caller need to implement fallback method. Return a true means the
* rendering request get done successfully. */
extern _X_EXPORT Bool glamor_fill_spans_nf(DrawablePtr drawable,
GCPtr gc,
int n, DDXPointPtr points,
@ -157,4 +187,22 @@ extern _X_EXPORT Bool glamor_triangles_nf(CARD8 op,
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_get_spans_nf(DrawablePtr drawable, int wmax,
DDXPointPtr points, int *widths, int count, char *dst);
extern _X_EXPORT Bool glamor_composite_rects_nf (CARD8 op,
PicturePtr pDst,
xRenderColor *color,
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_add_traps_nf(PicturePtr pPicture,
INT16 x_off,
INT16 y_off, int ntrap, xTrap * traps);

69
glamor/glamor_addtraps.c Normal file
View File

@ -0,0 +1,69 @@
/*
* Copyright © 2009 Intel Corporation
* Copyright © 1998 Keith Packard
*
* 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.
*
* Authors:
* Zhigang Gong <zhigang.gong@gmail.com>
*
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "glamor_priv.h"
static Bool
_glamor_add_traps(PicturePtr pPicture,
INT16 x_off,
INT16 y_off, int ntrap, xTrap * traps,
Bool fallback)
{
if (!fallback
&& ( !pPicture->pDrawable
|| glamor_ddx_fallback_check_pixmap(pPicture->pDrawable)))
return FALSE;
if (glamor_prepare_access_picture(pPicture, GLAMOR_ACCESS_RW)) {
fbAddTraps(pPicture, x_off, y_off, ntrap, traps);
glamor_finish_access_picture(pPicture, GLAMOR_ACCESS_RW);
}
return TRUE;
}
void
glamor_add_traps(PicturePtr pPicture,
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)
{
return _glamor_add_traps(pPicture, x_off, y_off, ntrap, traps, FALSE);
}

View File

@ -317,15 +317,17 @@ _glamor_copy_n_to_n(DrawablePtr src,
src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
screen = dst_pixmap->drawable.pScreen;
if (!dst_pixmap_priv || !src_pixmap_priv)
goto fail;
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dst_pixmap_priv)) {
if (!dst_pixmap_priv || !GLAMOR_PIXMAP_PRIV_HAS_FBO(dst_pixmap_priv)) {
glamor_fallback("dest pixmap %p has no fbo. \n",
dst_pixmap);
goto fail;
}
if (!src_pixmap_priv) {
glamor_set_pixmap_type(src_pixmap, GLAMOR_MEMORY);
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,
@ -398,7 +400,9 @@ _glamor_copy_n_to_n(DrawablePtr src,
fail:
if (!fallback) {
if (!fallback
&& glamor_ddx_fallback_check_pixmap(src)
&& glamor_ddx_fallback_check_pixmap(dst)) {
ret = FALSE;
goto done;
}

View File

@ -65,8 +65,7 @@
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)
@ -121,8 +120,6 @@ _glamor_egl_create_image(struct glamor_egl_screen_private *glamor_egl,
EGL_DRM_BUFFER_USE_SCANOUT_MESA,
EGL_NONE
};
attribs[1] = width;
attribs[3] = height;
attribs[5] = stride;
@ -221,14 +218,15 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
EGLImageKHR image;
GLuint texture;
int name;
int ret;
glamor_pixmap_type_t type;
if (!glamor_get_flink_name(glamor_egl->fd, handle, &name)) {
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
"Couldn't flink pixmap handle\n");
glamor_set_pixmap_type(pixmap, GLAMOR_MEMORY);
return FALSE;
glamor_set_pixmap_type(pixmap, GLAMOR_DRM_ONLY);
exit(1);
}
image = _glamor_egl_create_image(glamor_egl,
pixmap->drawable.width,
pixmap->drawable.height,
@ -236,18 +234,41 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
name,
pixmap->drawable.depth);
if (image == EGL_NO_IMAGE_KHR) {
glamor_set_pixmap_type(pixmap, GLAMOR_DRM_ONLY);
return FALSE;
GLenum format;
/* we have to create separated texture here. The reason is, if
* a DRM-buffer-only pixmap exist, and given a texture only
* pixmap as a source, then we will don't know how to render it
* within glamor, and we even can't find a good way to fallback
* to DDX driver, as DDX driver don't understand a texture only
* pixmap. */
type = GLAMOR_SEPARATE_TEXTURE;
if (pixmap->drawable.depth == 24)
format = GL_RGB;
else
format = GL_RGBA;
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);
glamor_egl->dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_NEAREST);
glamor_egl->dispatch->glTexImage2D(GL_TEXTURE_2D, 0, format, pixmap->drawable.width,
pixmap->drawable.height, 0, format,
GL_UNSIGNED_BYTE, NULL);
ret = FALSE;
} else {
type = GLAMOR_TEXTURE_DRM;
glamor_create_texture_from_image(glamor_egl, image, &texture);
ret = TRUE;
}
glamor_create_texture_from_image(glamor_egl, image, &texture);
glamor_set_pixmap_type(pixmap, type);
glamor_set_pixmap_texture(pixmap, pixmap->drawable.width,
pixmap->drawable.height, texture);
glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
dixSetPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key,
image);
return TRUE;
return ret;
}
void
@ -261,7 +282,7 @@ glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap)
if (pixmap->refcnt == 1) {
image = dixLookupPrivate(&pixmap->devPrivates,
glamor_egl_pixmap_private_key);
if (image != EGL_NO_IMAGE_KHR)
if (image != EGL_NO_IMAGE_KHR && image != NULL)
eglDestroyImageKHR(glamor_egl->display, image);
}
glamor_destroy_textured_pixmap(pixmap);
@ -357,10 +378,10 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
xf86Msg(X_INFO, "%s: EGL version %s:\n", glamor_name, version);
#define GLAMOR_CHECK_EGL_EXTENSION(EXT) \
if (!glamor_egl_has_extension(glamor_egl, "EGL_" #EXT)) { \
ErrorF("EGL_" #EXT "required.\n"); \
return FALSE; \
}
if (!glamor_egl_has_extension(glamor_egl, "EGL_" #EXT)) { \
ErrorF("EGL_" #EXT "required.\n"); \
return FALSE; \
}
GLAMOR_CHECK_EGL_EXTENSION(MESA_drm_image);
GLAMOR_CHECK_EGL_EXTENSION(KHR_gl_renderbuffer_image);

View File

@ -82,7 +82,12 @@ glamor_fill(DrawablePtr drawable,
return TRUE;
fail:
if (!fallback) return FALSE;
if (!fallback) {
if (glamor_ddx_fallback_check_pixmap(&dst_pixmap->drawable)
&& glamor_ddx_fallback_check_gc(gc))
return FALSE;
}
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
if (glamor_prepare_access_gc(gc)) {
fbFill(drawable, gc, x, y, width, height);

View File

@ -74,7 +74,10 @@ _glamor_fill_spans(DrawablePtr drawable,
return TRUE;
fail:
if (!fallback) return FALSE;
if (!fallback
&& glamor_ddx_fallback_check_pixmap(drawable)
&& glamor_ddx_fallback_check_gc(gc))
return FALSE;
glamor_fallback("to %p (%c)\n", drawable,
glamor_get_drawable_location(drawable));
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {

59
glamor/glamor_getimage.c Normal file
View File

@ -0,0 +1,59 @@
/*
* Copyright © 2009 Intel Corporation
* Copyright © 1998 Keith Packard
*
* 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.
*
* Authors:
* Zhigang Gong <zhigang.gong@gmail.com>
*
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "glamor_priv.h"
static Bool
_glamor_get_image(DrawablePtr pDrawable, int x, int y, int w, int h,
unsigned int format, unsigned long planeMask, char *d,
Bool fallback)
{
miGetImage(pDrawable, x, y, w, h, format, planeMask, d);
return TRUE;
}
void
glamor_get_image(DrawablePtr pDrawable, int x, int y, int w, int h,
unsigned int format, unsigned long planeMask, char *d)
{
_glamor_get_image(pDrawable, x, y, w, h, format, planeMask, d, TRUE);
return;
}
Bool
glamor_get_image_nf(DrawablePtr pDrawable, int x, int y, int w, int h,
unsigned int format, unsigned long planeMask, char *d)
{
return _glamor_get_image(pDrawable, x, y, w,
h, format, planeMask, d, FALSE);
}

View File

@ -31,10 +31,11 @@
#include "glamor_priv.h"
void
glamor_get_spans(DrawablePtr drawable,
int wmax,
DDXPointPtr points, int *widths, int count, char *dst)
static Bool
_glamor_get_spans(DrawablePtr drawable,
int wmax,
DDXPointPtr points, int *widths, int count, char *dst,
Bool fallback)
{
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
GLenum format, type;
@ -49,7 +50,7 @@ glamor_get_spans(DrawablePtr drawable,
uint8_t *readpixels_dst = (uint8_t *) dst;
int x_off, y_off;
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
if (!pixmap_priv || !GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
glamor_fallback("pixmap has no fbo.\n");
goto fail;
}
@ -94,14 +95,39 @@ glamor_get_spans(DrawablePtr drawable,
}
if (temp_pixmap)
glamor_destroy_pixmap(temp_pixmap);
return;
return TRUE;
fail:
if (!fallback
&& glamor_ddx_fallback_check_pixmap(drawable))
return FALSE;
glamor_fallback("from %p (%c)\n", drawable,
glamor_get_drawable_location(drawable));
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RO)) {
fbGetSpans(drawable, wmax, points, widths, count, dst);
glamor_finish_access(drawable, GLAMOR_ACCESS_RO);
}
return TRUE;
}
void
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);
}
Bool
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);
}

View File

@ -184,7 +184,7 @@ glamor_realize_glyph_caches(ScreenPtr pScreen)
CPComponentAlpha, &component_alpha,
serverClient, &error);
glamor_destroy_pixmap(pixmap);
pScreen->DestroyPixmap(pixmap);
if (!picture)
goto bail;
@ -239,12 +239,57 @@ glamor_glyph_cache_upload_glyph(ScreenPtr screen,
ValidateGC(&pCachePixmap->drawable, gc);
scratch = pGlyphPixmap;
if (pGlyphPixmap->drawable.depth != pCachePixmap->drawable.depth) {
scratch = glamor_create_pixmap(screen,
glyph->info.width,
glyph->info.height,
pCachePixmap->
drawable.depth, 0);
if (scratch) {
if (pGlyphPixmap->drawable.depth !=
pCachePixmap->drawable.depth) {
PicturePtr picture;
int error;
picture =
CreatePicture(0,
&scratch->drawable,
PictureMatchFormat
(screen,
pCachePixmap->
drawable.depth,
cache->picture->format),
0, NULL, serverClient,
&error);
if (picture) {
ValidatePicture(picture);
glamor_composite(PictOpSrc,
pGlyphPicture,
NULL, picture,
0, 0, 0, 0, 0,
0,
glyph->info.width,
glyph->info.height);
FreePicture(picture, 0);
}
} else {
glamor_copy_area(&pGlyphPixmap->drawable,
&scratch->drawable,
gc, 0, 0,
glyph->info.width,
glyph->info.height, 0, 0);
}
} else {
scratch = pGlyphPixmap;
}
}
(*gc->ops->CopyArea)(&scratch->drawable, &pCachePixmap->drawable, gc,
0, 0, glyph->info.width, glyph->info.height, x,
y);
if (scratch != pGlyphPixmap)
glamor_destroy_pixmap(scratch);
screen->DestroyPixmap(scratch);
FreeScratchGC(gc);
}
@ -581,8 +626,8 @@ static void
glamor_glyphs_flush_mask(PicturePtr mask, glamor_glyph_buffer_t * buffer)
{
#ifdef RENDER
glamor_composite_rects(PictOpAdd, buffer->source, NULL, mask,
buffer->count, buffer->rects);
glamor_composite_glyph_rects(PictOpAdd, buffer->source, NULL, mask,
buffer->count, buffer->rects);
#endif
buffer->count = 0;
buffer->source = NULL;
@ -638,7 +683,7 @@ glamor_glyphs_via_mask(CARD8 op,
mask_format, CPComponentAlpha,
&component_alpha, serverClient, &error);
if (!mask) {
glamor_destroy_pixmap(mask_pixmap);
screen->DestroyPixmap(mask_pixmap);
return;
}
gc = GetScratchGC(mask_pixmap->drawable.depth, screen);
@ -695,7 +740,7 @@ glamor_glyphs_via_mask(CARD8 op,
x_src + x - x_dst,
y_src + y - y_dst, 0, 0, x, y, width, height);
FreePicture(mask, 0);
glamor_destroy_pixmap(mask_pixmap);
screen->DestroyPixmap(mask_pixmap);
}
static void
@ -714,7 +759,7 @@ glamor_glyphs_flush_dst(CARD8 op,
rect->y_src = y_src + rect->y_dst - y_dst;
}
glamor_composite_rects(op, src, buffer->source, dst,
glamor_composite_glyph_rects(op, src, buffer->source, dst,
buffer->count, &buffer->rects[0]);
buffer->count = 0;

View File

@ -42,7 +42,7 @@ glamor_finish_access_picture(PicturePtr picture, glamor_access_t access)
}
/*
* We should already has drawable attached to it, if it has one.
* We should already have drawable attached to it, if it has one.
* Then set the attached pixmap to is_picture format, and set
* the pict format.
* */
@ -64,6 +64,10 @@ glamor_create_picture(PicturePtr picture)
if (pixmap_priv) {
pixmap_priv->is_picture = 1;
pixmap_priv->pict_format = picture->format;
/* XXX Some formats are compatible between glamor and ddx driver*/
if (pixmap_priv->type == GLAMOR_TEXTURE_DRM
/*&& pixmap_priv->pict_format != PICT_b8g8r8a8*/)
glamor_set_pixmap_type(pixmap, GLAMOR_SEPARATE_TEXTURE);
}
return glamor_priv->saved_create_picture(picture);
}

View File

@ -94,7 +94,12 @@ _glamor_poly_fill_rect(DrawablePtr drawable,
return TRUE;
fail:
if (!fallback) return FALSE;
if (!fallback
&& glamor_ddx_fallback_check_pixmap(drawable)
&& glamor_ddx_fallback_check_gc(gc))
return FALSE;
glamor_fallback(" to %p (%c)\n",
drawable, glamor_get_drawable_location(drawable));
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {

View File

@ -147,6 +147,7 @@ typedef struct glamor_screen_private {
CopyWindowProcPtr saved_copy_window;
BitmapToRegionProcPtr saved_bitmap_to_region;
TrianglesProcPtr saved_triangles;
AddTrapsProcPtr saved_addtraps;
CreatePictureProcPtr saved_create_picture;
DestroyPictureProcPtr saved_destroy_picture;
UnrealizeGlyphProcPtr saved_unrealize_glyph;
@ -444,10 +445,16 @@ void glamor_trapezoids(CARD8 op,
PictFormatPtr mask_format, INT16 x_src, INT16 y_src,
int ntrap, xTrapezoid * traps);
void glamor_init_composite_shaders(ScreenPtr screen);
void glamor_composite_rects(CARD8 op,
PicturePtr src, PicturePtr mask,
PicturePtr dst, int nrect,
glamor_composite_rect_t * rects);
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,
PicturePtr pDst,
xRenderColor *color,
int nRect,
xRectangle *rects);
/* glamor_tile.c */
Bool glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
@ -536,10 +543,19 @@ enum glamor_pixmap_status
glamor_upload_picture_to_texture(PicturePtr picture);
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,
unsigned int format, unsigned long planeMask, char *d);
void
glamor_add_traps(PicturePtr pPicture,
INT16 x_off,
INT16 y_off, int ntrap, xTrap * traps);
#include"glamor_utils.h"
/* Dynamic pixmap upload to texture if needed.

View File

@ -395,7 +395,11 @@ _glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
fail:
glamor_set_planemask(pixmap, ~0);
if (!fallback) return FALSE;
if (!fallback
&& glamor_ddx_fallback_check_pixmap(&pixmap->drawable))
return FALSE;
glamor_fallback("to %p (%c)\n",
drawable, glamor_get_drawable_location(drawable));
if (glamor_prepare_access(&pixmap->drawable, GLAMOR_ACCESS_RW)) {

View File

@ -1155,7 +1155,6 @@ glamor_convert_gradient_picture(ScreenPtr screen,
PicturePtr dst;
int error;
PictFormatShort format;
if (!source->pDrawable)
format = PICT_a8r8g8b8;
else
@ -1176,7 +1175,7 @@ glamor_convert_gradient_picture(ScreenPtr screen,
PIXMAN_FORMAT_DEPTH(format),
format),
0, 0, serverClient, &error);
screen->DestroyPixmap(pixmap);
glamor_destroy_pixmap(pixmap);
if (!dst)
return NULL;
@ -1226,18 +1225,24 @@ _glamor_composite(CARD8 op,
}
if (source->pDrawable) {
source_pixmap =
glamor_get_drawable_pixmap(source->pDrawable);
source_pixmap_priv =
glamor_get_pixmap_private(source_pixmap);
if (!source_pixmap_priv || source_pixmap_priv->type == GLAMOR_DRM_ONLY)
source_pixmap = glamor_get_drawable_pixmap(source->pDrawable);
source_pixmap_priv = glamor_get_pixmap_private(source_pixmap);
if (!source_pixmap_priv) {
glamor_set_pixmap_type(source_pixmap, GLAMOR_MEMORY);
source_pixmap_priv = glamor_get_pixmap_private(source_pixmap);
}
if (source_pixmap_priv->type == GLAMOR_DRM_ONLY)
goto fail;
}
if (mask && mask->pDrawable) {
mask_pixmap = glamor_get_drawable_pixmap(mask->pDrawable);
mask_pixmap_priv = glamor_get_pixmap_private(mask_pixmap);
if (!mask_pixmap_priv || mask_pixmap_priv->type == GLAMOR_DRM_ONLY)
if (!mask_pixmap_priv) {
glamor_set_pixmap_type(mask_pixmap, GLAMOR_MEMORY);
mask_pixmap_priv = glamor_get_pixmap_private(mask_pixmap);
}
if (mask_pixmap_priv->type == GLAMOR_DRM_ONLY)
goto fail;
}
if ((!source->pDrawable
@ -1336,10 +1341,17 @@ _glamor_composite(CARD8 op,
dispatch->glUseProgram(0);
dispatch->glDisable(GL_BLEND);
if (!fallback) {
if (!fallback
&& glamor_ddx_fallback_check_pixmap(&dest_pixmap->drawable)
&& (!source_pixmap
|| glamor_ddx_fallback_check_pixmap(&source_pixmap->drawable))
&& (!mask_pixmap
|| glamor_ddx_fallback_check_pixmap(&mask_pixmap->drawable))) {
ret = FALSE;
goto done;
}
fallback:
glamor_fallback
("from picts %p:%p %dx%d / %p:%p %d x %d (%c,%c) to pict %p:%p %dx%d (%c)\n",
source, source->pDrawable,
@ -1564,9 +1576,9 @@ glamor_trapezoids_nf(CARD8 op,
void
glamor_composite_rects(CARD8 op,
PicturePtr src, PicturePtr mask, PicturePtr dst,
int nrect, glamor_composite_rect_t * rects)
glamor_composite_glyph_rects(CARD8 op,
PicturePtr src, PicturePtr mask, PicturePtr dst,
int nrect, glamor_composite_rect_t * rects)
{
int n;
glamor_composite_rect_t *r;
@ -1592,4 +1604,38 @@ glamor_composite_rects(CARD8 op,
}
}
static Bool
_glamor_composite_rects (CARD8 op,
PicturePtr pDst,
xRenderColor *color,
int nRect,
xRectangle *rects,
Bool fallback)
{
miCompositeRects(op, pDst, color, nRect, rects);
return TRUE;
}
void
glamor_composite_rects (CARD8 op,
PicturePtr pDst,
xRenderColor *color,
int nRect,
xRectangle *rects)
{
_glamor_composite_rects(op, pDst, color, nRect, rects, TRUE);
}
Bool
glamor_composite_rects_nf (CARD8 op,
PicturePtr pDst,
xRenderColor *color,
int nRect,
xRectangle *rects)
{
return _glamor_composite_rects(op, pDst, color, nRect, rects, FALSE);
}
#endif /* RENDER */

View File

@ -31,9 +31,10 @@
#include "glamor_priv.h"
void
glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
DDXPointPtr points, int *widths, int n, int sorted)
static Bool
_glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
DDXPointPtr points, int *widths, int n, int sorted,
Bool fallback)
{
PixmapPtr dest_pixmap = glamor_get_drawable_pixmap(drawable);
glamor_screen_private *glamor_priv =
@ -94,13 +95,32 @@ glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
glamor_set_planemask(dest_pixmap, ~0);
glamor_set_alu(dispatch, GXcopy);
dispatch->glDisable(GL_SCISSOR_TEST);
return;
return TRUE;
fail:
if (!fallback
&& glamor_ddx_fallback_check_pixmap(drawable))
return FALSE;
glamor_fallback("to %p (%c)\n",
drawable, glamor_get_drawable_location(drawable));
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
fbSetSpans(drawable, gc, src, points, widths, n, sorted);
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
}
return TRUE;
}
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);
}
Bool
glamor_set_spans_nf(DrawablePtr drawable, GCPtr gc, char *src,
DDXPointPtr points, int *widths, int n, int sorted)
{
return _glamor_set_spans(drawable, gc, src, points,
widths, n, sorted, FALSE);
}

View File

@ -39,20 +39,23 @@ _glamor_triangles(CARD8 op,
PictFormatPtr maskFormat,
INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris, Bool fallback)
{
if (!fallback)
if (!fallback
&& glamor_ddx_fallback_check_pixmap(pDst->pDrawable)
&& (!pSrc->pDrawable
|| glamor_ddx_fallback_check_pixmap(pSrc->pDrawable)))
return FALSE;
if (glamor_prepare_access(pDst->pDrawable, GLAMOR_ACCESS_RW)) {
if (pSrc->pDrawable == NULL ||
glamor_prepare_access(pSrc->pDrawable,
GLAMOR_ACCESS_RO)) {
if (glamor_prepare_access_picture(pDst, GLAMOR_ACCESS_RW)) {
if (glamor_prepare_access_picture(pSrc,
GLAMOR_ACCESS_RO)) {
fbTriangles(op, pSrc, pDst, maskFormat, xSrc,
ySrc, ntris, tris);
}
if (pSrc->pDrawable != NULL)
glamor_finish_access(pSrc->pDrawable, GLAMOR_ACCESS_RO);
glamor_finish_access(pDst->pDrawable, GLAMOR_ACCESS_RW);
glamor_finish_access_picture(pSrc, GLAMOR_ACCESS_RO);
}
glamor_finish_access_picture(pDst, GLAMOR_ACCESS_RW);
}
return TRUE;
}

View File

@ -541,9 +541,34 @@ glamor_get_rgba_from_pixel(CARD32 pixel,
return TRUE;
}
/* return TRUE if we can access this pixmap at DDX driver. */
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)
{
PixmapPtr pixmap;
if (!gc)
return TRUE;
switch (gc->fillStyle) {
case FillStippled:
case FillOpaqueStippled:
pixmap = gc->stipple;
break;
case FillTiled:
pixmap = gc->tile.pixmap;
break;
default:
pixmap = NULL;
}
return (!pixmap || glamor_ddx_fallback_check_pixmap(&pixmap->drawable));
}
#endif