3
* Copyright ® 2001 Keith Packard
5
* Partly based on code that is Copyright ® The XFree86 Project Inc.
7
* Permission to use, copy, modify, distribute, and sell this software and its
8
* documentation for any purpose is hereby granted without fee, provided that
9
* the above copyright notice appear in all copies and that both that
10
* copyright notice and this permission notice appear in supporting
11
* documentation, and that the name of Keith Packard not be used in
12
* advertising or publicity pertaining to distribution of the software without
13
* specific, written prior permission. Keith Packard makes no
14
* representations about the suitability of this software for any purpose. It
15
* is provided "as is" without express or implied warranty.
17
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
18
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
19
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
20
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
22
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23
* PERFORMANCE OF THIS SOFTWARE.
26
* Eric Anholt <eric@anholt.net>
27
* Michel Dänzer <michel@tungstengraphics.com>
31
#ifdef HAVE_DIX_CONFIG_H
32
#include <dix-config.h>
35
#include "uxa-glamor.h"
36
#include <X11/fonts/fontstruct.h>
37
#include "dixfontstr.h"
41
uxa_fill_spans(DrawablePtr pDrawable, GCPtr pGC, int n,
42
DDXPointPtr ppt, int *pwidth, int fSorted)
44
ScreenPtr screen = pDrawable->pScreen;
45
uxa_screen_t *uxa_screen = uxa_get_screen(screen);
46
RegionPtr pClip = fbGetCompositeClip(pGC);
53
if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
56
if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
57
ok = glamor_fill_spans_nf(pDrawable,
58
pGC, n, ppt, pwidth, fSorted);
59
uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
68
if (uxa_screen->force_fallback)
71
if (pGC->fillStyle != FillSolid)
74
dst_pixmap = uxa_get_offscreen_pixmap(pDrawable, &off_x, &off_y);
78
if (uxa_screen->info->check_solid &&
79
!uxa_screen->info->check_solid(pDrawable, pGC->alu, pGC->planemask))
82
if (!(*uxa_screen->info->prepare_solid) (dst_pixmap,
91
x2 = x1 + (int)*pwidth;
95
nbox = REGION_NUM_RECTS(pClip);
96
pbox = REGION_RECTS(pClip);
105
if (X2 > X1 && pbox->y1 <= y && pbox->y2 > y)
106
(*uxa_screen->info->solid) (dst_pixmap,
107
X1 + off_x, y + off_y,
108
X2 + off_x, y + 1 + off_y);
112
(*uxa_screen->info->done_solid) (dst_pixmap);
117
uxa_check_fill_spans(pDrawable, pGC, n, ppt, pwidth, fSorted);
121
uxa_do_put_image(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
122
int w, int h, int format, char *bits, int src_stride)
124
uxa_screen_t *uxa_screen = uxa_get_screen(pDrawable->pScreen);
130
int bpp = pDrawable->bitsPerPixel;
132
/* Don't bother with under 8bpp, XYPixmaps. */
133
if (format != ZPixmap || bpp < 8)
136
if (uxa_screen->force_fallback)
139
if (!uxa_screen->info->put_image)
142
/* Only accelerate copies: no rop or planemask. */
143
if (!UXA_PM_IS_SOLID(pDrawable, pGC->planemask) || pGC->alu != GXcopy)
146
pPix = uxa_get_offscreen_pixmap(pDrawable, &xoff, &yoff);
153
pClip = fbGetCompositeClip(pGC);
154
for (nbox = REGION_NUM_RECTS(pClip),
155
pbox = REGION_RECTS(pClip); nbox--; pbox++) {
171
if (x1 >= x2 || y1 >= y2)
174
src = bits + (y1 - y) * src_stride + (x1 - x) * (bpp / 8);
175
ok = uxa_screen->info->put_image(pPix, x1 + xoff, y1 + yoff,
176
x2 - x1, y2 - y1, src,
178
/* If we fail to accelerate the upload, fall back to using
179
* unaccelerated fb calls.
185
int dstXoff, dstYoff;
187
if (!uxa_prepare_access(pDrawable, UXA_ACCESS_RW))
190
fbGetStipDrawable(pDrawable, dst, dst_stride, dstBpp,
193
fbBltStip((FbStip *) bits +
194
(y1 - y) * (src_stride / sizeof(FbStip)),
195
src_stride / sizeof(FbStip),
197
dst + (y1 + dstYoff) * dst_stride, dst_stride,
198
(x1 + dstXoff) * dstBpp, (x2 - x1) * dstBpp,
199
y2 - y1, GXcopy, FB_ALLONES, dstBpp);
201
uxa_finish_access(pDrawable, UXA_ACCESS_RW);
210
uxa_put_image(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
211
int w, int h, int leftPad, int format, char *bits)
213
uxa_screen_t *uxa_screen = uxa_get_screen(pDrawable->pScreen);
215
if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
218
if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
219
ok = glamor_put_image_nf(pDrawable,
220
pGC, depth, x, y, w, h,
221
leftPad, format, bits);
222
uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
230
if (!uxa_do_put_image(pDrawable, pGC, depth, x, y, w, h, format, bits,
231
PixmapBytePad(w, pDrawable->depth))) {
233
uxa_check_put_image(pDrawable, pGC, depth, x, y, w, h, leftPad,
239
uxa_copy_n_to_n_two_dir(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
240
GCPtr pGC, BoxPtr pbox, int nbox, int dx, int dy)
242
uxa_screen_t *uxa_screen = uxa_get_screen(pDstDrawable->pScreen);
243
PixmapPtr pSrcPixmap, pDstPixmap;
244
int src_off_x, src_off_y, dst_off_x, dst_off_y;
247
/* Need to get both pixmaps to call the driver routines */
249
uxa_get_offscreen_pixmap(pSrcDrawable, &src_off_x, &src_off_y);
251
uxa_get_offscreen_pixmap(pDstDrawable, &dst_off_x, &dst_off_y);
252
if (!pSrcPixmap || !pDstPixmap)
256
* Now the case of a chip that only supports xdir = ydir = 1 or
257
* xdir = ydir = -1, but we have xdir != ydir.
259
dirsetup = 0; /* No direction set up yet. */
260
for (; nbox; pbox++, nbox--) {
261
if (dx >= 0 && (src_off_y + pbox->y1 + dy) != pbox->y1) {
262
/* Do a xdir = ydir = -1 blit instead. */
263
if (dirsetup != -1) {
265
uxa_screen->info->done_copy(pDstPixmap);
267
if (!(*uxa_screen->info->prepare_copy)
268
(pSrcPixmap, pDstPixmap, -1, -1,
269
pGC ? pGC->alu : GXcopy,
270
pGC ? pGC->planemask : FB_ALLONES))
273
(*uxa_screen->info->copy) (pDstPixmap,
274
src_off_x + pbox->x1 + dx,
275
src_off_y + pbox->y1 + dy,
276
dst_off_x + pbox->x1,
277
dst_off_y + pbox->y1,
279
pbox->y2 - pbox->y1);
280
} else if (dx < 0 && (src_off_y + pbox->y1 + dy) != pbox->y1) {
281
/* Do a xdir = ydir = 1 blit instead. */
284
uxa_screen->info->done_copy(pDstPixmap);
286
if (!(*uxa_screen->info->prepare_copy)
287
(pSrcPixmap, pDstPixmap, 1, 1,
288
pGC ? pGC->alu : GXcopy,
289
pGC ? pGC->planemask : FB_ALLONES))
292
(*uxa_screen->info->copy) (pDstPixmap,
293
src_off_x + pbox->x1 + dx,
294
src_off_y + pbox->y1 + dy,
295
dst_off_x + pbox->x1,
296
dst_off_y + pbox->y1,
298
pbox->y2 - pbox->y1);
299
} else if (dx >= 0) {
301
* xdir = 1, ydir = -1.
302
* Perform line-by-line xdir = ydir = 1 blits, going up.
307
uxa_screen->info->done_copy(pDstPixmap);
309
if (!(*uxa_screen->info->prepare_copy)
310
(pSrcPixmap, pDstPixmap, 1, 1,
311
pGC ? pGC->alu : GXcopy,
312
pGC ? pGC->planemask : FB_ALLONES))
315
for (i = pbox->y2 - pbox->y1 - 1; i >= 0; i--)
316
(*uxa_screen->info->copy) (pDstPixmap,
321
dst_off_x + pbox->x1,
328
* xdir = -1, ydir = 1.
329
* Perform line-by-line xdir = ydir = -1 blits,
333
if (dirsetup != -1) {
335
uxa_screen->info->done_copy(pDstPixmap);
337
if (!(*uxa_screen->info->prepare_copy)
338
(pSrcPixmap, pDstPixmap, -1, -1,
339
pGC ? pGC->alu : GXcopy,
340
pGC ? pGC->planemask : FB_ALLONES))
343
for (i = 0; i < pbox->y2 - pbox->y1; i++)
344
(*uxa_screen->info->copy) (pDstPixmap,
349
dst_off_x + pbox->x1,
357
uxa_screen->info->done_copy(pDstPixmap);
362
uxa_copy_n_to_n(DrawablePtr pSrcDrawable,
363
DrawablePtr pDstDrawable,
369
Bool reverse, Bool upsidedown, Pixel bitplane, void *closure)
371
ScreenPtr screen = pDstDrawable->pScreen;
372
uxa_screen_t *uxa_screen = uxa_get_screen(screen);
373
int src_off_x, src_off_y;
374
int dst_off_x, dst_off_y;
375
PixmapPtr pSrcPixmap, pDstPixmap;
377
if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
380
if (uxa_prepare_access(pSrcDrawable, UXA_GLAMOR_ACCESS_RO)) {
381
if (uxa_prepare_access(pDstDrawable, UXA_GLAMOR_ACCESS_RW)) {
382
ok = glamor_copy_n_to_n_nf(pSrcDrawable, pDstDrawable,
383
pGC, pbox, nbox, dx, dy,
384
reverse, upsidedown, bitplane,
386
uxa_finish_access(pDstDrawable, UXA_GLAMOR_ACCESS_RW);
388
uxa_finish_access(pSrcDrawable, UXA_GLAMOR_ACCESS_RO);
397
if (uxa_screen->force_fallback)
400
pSrcPixmap = uxa_get_drawable_pixmap(pSrcDrawable);
401
pDstPixmap = uxa_get_drawable_pixmap(pDstDrawable);
402
if (!pSrcPixmap || !pDstPixmap)
405
if (uxa_screen->info->check_copy &&
406
!uxa_screen->info->check_copy(pSrcPixmap, pDstPixmap,
407
pGC ? pGC->alu : GXcopy,
408
pGC ? pGC->planemask : FB_ALLONES))
411
uxa_get_drawable_deltas(pSrcDrawable, pSrcPixmap, &src_off_x,
413
uxa_get_drawable_deltas(pDstDrawable, pDstPixmap, &dst_off_x,
416
/* Mixed directions must be handled specially if the card is lame */
417
if ((uxa_screen->info->flags & UXA_TWO_BITBLT_DIRECTIONS) &&
418
reverse != upsidedown) {
419
if (uxa_copy_n_to_n_two_dir
420
(pSrcDrawable, pDstDrawable, pGC, pbox, nbox, dx, dy))
425
if (!uxa_pixmap_is_offscreen(pDstPixmap)) {
429
if (!uxa_pixmap_is_offscreen(pSrcPixmap))
432
if (!uxa_screen->info->get_image)
435
/* Don't bother with under 8bpp, XYPixmaps. */
436
bpp = pSrcPixmap->drawable.bitsPerPixel;
437
if (bpp != pDstDrawable->bitsPerPixel || bpp < 8)
440
/* Only accelerate copies: no rop or planemask. */
441
if (pGC && (!UXA_PM_IS_SOLID(pSrcDrawable, pGC->planemask) || pGC->alu != GXcopy))
444
dst = pDstPixmap->devPrivate.ptr;
445
stride = pDstPixmap->devKind;
448
if (!uxa_screen->info->get_image(pSrcPixmap,
449
pbox->x1 + dx + src_off_x,
450
pbox->y1 + dy + src_off_y,
454
(pbox->y1 + dst_off_y) * stride +
455
(pbox->x1 + dst_off_x) * bpp,
465
if (uxa_pixmap_is_offscreen(pSrcPixmap)) {
466
if (!(*uxa_screen->info->prepare_copy) (pSrcPixmap, pDstPixmap,
469
pGC ? pGC->alu : GXcopy,
471
planemask : FB_ALLONES))
475
(*uxa_screen->info->copy) (pDstPixmap,
476
pbox->x1 + dx + src_off_x,
477
pbox->y1 + dy + src_off_y,
478
pbox->x1 + dst_off_x,
479
pbox->y1 + dst_off_y,
481
pbox->y2 - pbox->y1);
485
(*uxa_screen->info->done_copy) (pDstPixmap);
490
if (!uxa_screen->info->put_image)
493
/* Don't bother with under 8bpp, XYPixmaps. */
494
bpp = pSrcPixmap->drawable.bitsPerPixel;
495
if (bpp != pDstDrawable->bitsPerPixel || bpp < 8)
498
/* Only accelerate copies: no rop or planemask. */
499
if (pGC && (!UXA_PM_IS_SOLID(pSrcDrawable, pGC->planemask) || pGC->alu != GXcopy))
502
src = pSrcPixmap->devPrivate.ptr;
503
stride = pSrcPixmap->devKind;
506
if (!uxa_screen->info->put_image(pDstPixmap,
507
pbox->x1 + dst_off_x,
508
pbox->y1 + dst_off_y,
512
(pbox->y1 + dy + src_off_y) * stride +
513
(pbox->x1 + dx + src_off_x) * bpp,
524
UXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrcDrawable, pDstDrawable,
525
uxa_drawable_location(pSrcDrawable),
526
uxa_drawable_location(pDstDrawable)));
527
if (uxa_prepare_access(pDstDrawable, UXA_ACCESS_RW)) {
528
if (pSrcDrawable == pDstDrawable ||
529
uxa_prepare_access(pSrcDrawable, UXA_ACCESS_RO)) {
530
fbCopyNtoN(pSrcDrawable, pDstDrawable, pGC, pbox, nbox,
531
dx, dy, reverse, upsidedown, bitplane,
533
if (pSrcDrawable != pDstDrawable)
534
uxa_finish_access(pSrcDrawable, UXA_ACCESS_RO);
536
uxa_finish_access(pDstDrawable, UXA_ACCESS_RW);
541
uxa_copy_area(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
542
int srcx, int srcy, int width, int height, int dstx, int dsty)
544
uxa_screen_t *uxa_screen = uxa_get_screen(pDstDrawable->pScreen);
546
if (uxa_screen->force_fallback) {
547
return uxa_check_copy_area(pSrcDrawable, pDstDrawable, pGC,
548
srcx, srcy, width, height, dstx,
552
return miDoCopy(pSrcDrawable, pDstDrawable, pGC,
553
srcx, srcy, width, height,
554
dstx, dsty, uxa_copy_n_to_n, 0, NULL);
558
uxa_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
563
uxa_screen_t *uxa_screen = uxa_get_screen(pDrawable->pScreen);
565
if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
568
if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
569
ok = glamor_poly_point_nf(pDrawable, pGC, mode, npt, ppt);
570
uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
577
/* If we can't reuse the current GC as is, don't bother accelerating the
580
if (pGC->fillStyle != FillSolid) {
581
uxa_check_poly_point(pDrawable, pGC, mode, npt, ppt);
585
prect = malloc(sizeof(xRectangle) * npt);
588
for (i = 0; i < npt; i++) {
589
prect[i].x = ppt[i].x;
590
prect[i].y = ppt[i].y;
591
if (i > 0 && mode == CoordModePrevious) {
592
prect[i].x += prect[i - 1].x;
593
prect[i].y += prect[i - 1].y;
598
pGC->ops->PolyFillRect(pDrawable, pGC, npt, prect);
603
* uxa_poly_lines() checks if it can accelerate the lines as a group of
604
* horizontal or vertical lines (rectangles), and uses existing rectangle fill
605
* acceleration if so.
608
uxa_poly_lines(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
614
uxa_screen_t *uxa_screen = uxa_get_screen(pDrawable->pScreen);
616
if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
619
if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
620
ok = glamor_poly_lines_nf(pDrawable, pGC, mode, npt, ppt);
621
uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
628
/* Don't try to do wide lines or non-solid fill style. */
629
if (pGC->lineWidth != 0 || pGC->lineStyle != LineSolid ||
630
pGC->fillStyle != FillSolid) {
631
uxa_check_poly_lines(pDrawable, pGC, mode, npt, ppt);
635
prect = malloc(sizeof(xRectangle) * (npt - 1));
640
/* If we have any non-horizontal/vertical, fall back. */
641
for (i = 0; i < npt - 1; i++) {
642
if (mode == CoordModePrevious) {
643
x2 = x1 + ppt[i + 1].x;
644
y2 = y1 + ppt[i + 1].y;
650
if (x1 != x2 && y1 != y2) {
652
uxa_check_poly_lines(pDrawable, pGC, mode, npt, ppt);
658
prect[i].width = x2 - x1 + 1;
661
prect[i].width = x1 - x2 + 1;
665
prect[i].height = y2 - y1 + 1;
668
prect[i].height = y1 - y2 + 1;
674
pGC->ops->PolyFillRect(pDrawable, pGC, npt - 1, prect);
679
* uxa_poly_segment() checks if it can accelerate the lines as a group of
680
* horizontal or vertical lines (rectangles), and uses existing rectangle fill
681
* acceleration if so.
684
uxa_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pSeg)
688
uxa_screen_t *uxa_screen = uxa_get_screen(pDrawable->pScreen);
690
if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
693
if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
694
ok = glamor_poly_segment_nf(pDrawable, pGC, nseg, pSeg);
695
uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
702
/* Don't try to do wide lines or non-solid fill style. */
703
if (pGC->lineWidth != 0 || pGC->lineStyle != LineSolid ||
704
pGC->fillStyle != FillSolid) {
705
uxa_check_poly_segment(pDrawable, pGC, nseg, pSeg);
709
/* If we have any non-horizontal/vertical, fall back. */
710
for (i = 0; i < nseg; i++) {
711
if (pSeg[i].x1 != pSeg[i].x2 && pSeg[i].y1 != pSeg[i].y2) {
712
uxa_check_poly_segment(pDrawable, pGC, nseg, pSeg);
717
prect = malloc(sizeof(xRectangle) * nseg);
720
for (i = 0; i < nseg; i++) {
721
if (pSeg[i].x1 < pSeg[i].x2) {
722
prect[i].x = pSeg[i].x1;
723
prect[i].width = pSeg[i].x2 - pSeg[i].x1 + 1;
725
prect[i].x = pSeg[i].x2;
726
prect[i].width = pSeg[i].x1 - pSeg[i].x2 + 1;
728
if (pSeg[i].y1 < pSeg[i].y2) {
729
prect[i].y = pSeg[i].y1;
730
prect[i].height = pSeg[i].y2 - pSeg[i].y1 + 1;
732
prect[i].y = pSeg[i].y2;
733
prect[i].height = pSeg[i].y1 - pSeg[i].y2 + 1;
736
/* don't paint last pixel */
737
if (pGC->capStyle == CapNotLast) {
738
if (prect[i].width == 1)
744
pGC->ops->PolyFillRect(pDrawable, pGC, nseg, prect);
748
static Bool uxa_fill_region_solid(DrawablePtr pDrawable, RegionPtr pRegion,
749
Pixel pixel, CARD32 planemask, CARD32 alu);
752
uxa_poly_fill_rect(DrawablePtr pDrawable,
753
GCPtr pGC, int nrect, xRectangle * prect)
755
uxa_screen_t *uxa_screen = uxa_get_screen(pDrawable->pScreen);
756
RegionPtr pClip = fbGetCompositeClip(pGC);
760
int fullX1, fullX2, fullY1, fullY2;
765
if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
768
if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
769
ok = glamor_poly_fill_rect_nf(pDrawable, pGC, nrect, prect);
770
uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
774
uxa_check_poly_fill_rect(pDrawable, pGC, nrect, prect);
779
/* Compute intersection of rects and clip region */
780
pReg = RECTS_TO_REGION(pScreen, nrect, prect, CT_UNSORTED);
781
REGION_TRANSLATE(pScreen, pReg, pDrawable->x, pDrawable->y);
782
REGION_INTERSECT(pScreen, pReg, pClip, pReg);
784
if (!REGION_NUM_RECTS(pReg))
787
if (uxa_screen->force_fallback)
790
pPixmap = uxa_get_offscreen_pixmap (pDrawable, &xoff, &yoff);
794
/* For ROPs where overlaps don't matter, convert rectangles to region
795
* and call uxa_fill_region_{solid,tiled}.
797
if ((pGC->fillStyle == FillSolid || pGC->fillStyle == FillTiled) &&
798
(nrect == 1 || pGC->alu == GXcopy || pGC->alu == GXclear ||
799
pGC->alu == GXnoop || pGC->alu == GXcopyInverted ||
800
pGC->alu == GXset)) {
801
if (((pGC->fillStyle == FillSolid || pGC->tileIsPixel) &&
802
uxa_fill_region_solid(pDrawable, pReg,
804
FillSolid ? pGC->fgPixel : pGC->tile.
805
pixel, pGC->planemask, pGC->alu))
806
|| (pGC->fillStyle == FillTiled && !pGC->tileIsPixel
807
&& uxa_fill_region_tiled(pDrawable, pReg,
808
pGC->tile.pixmap, &pGC->patOrg,
809
pGC->planemask, pGC->alu))) {
814
if (pGC->fillStyle != FillSolid &&
815
!(pGC->tileIsPixel && pGC->fillStyle == FillTiled)) {
819
if (uxa_screen->info->check_solid &&
820
!uxa_screen->info->check_solid(pDrawable, pGC->alu, pGC->planemask)) {
824
if (!(*uxa_screen->info->prepare_solid) (pPixmap,
829
uxa_check_poly_fill_rect(pDrawable, pGC, nrect, prect);
837
fullX1 = prect->x + xorg;
838
fullY1 = prect->y + yorg;
839
fullX2 = fullX1 + (int)prect->width;
840
fullY2 = fullY1 + (int)prect->height;
843
n = REGION_NUM_RECTS(pClip);
844
pbox = REGION_RECTS(pClip);
846
* clip the rectangle to each box in the clip region
847
* this is logically equivalent to calling Intersect(),
848
* but rectangles may overlap each other here.
866
if (x1 >= x2 || y1 >= y2)
869
(*uxa_screen->info->solid) (pPixmap,
876
(*uxa_screen->info->done_solid) (pPixmap);
879
REGION_UNINIT(pScreen, pReg);
880
REGION_DESTROY(pScreen, pReg);
884
uxa_get_spans(DrawablePtr pDrawable,
886
DDXPointPtr ppt, int *pwidth, int nspans, char *pdstStart)
888
ScreenPtr screen = pDrawable->pScreen;
889
uxa_screen_t *uxa_screen = uxa_get_screen(screen);
891
if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
894
if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
895
ok = glamor_get_spans_nf(pDrawable, wMax, ppt,
896
pwidth, nspans, pdstStart);
897
uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
907
uxa_check_get_spans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
911
uxa_set_spans(DrawablePtr pDrawable, GCPtr gc, char *src,
912
DDXPointPtr points, int *widths, int n, int sorted)
914
ScreenPtr screen = pDrawable->pScreen;
915
uxa_screen_t *uxa_screen = uxa_get_screen(screen);
917
if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
920
if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
921
ok = glamor_set_spans_nf(pDrawable, gc, src,
922
points, widths, n, sorted);
923
uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
933
uxa_check_set_spans(pDrawable, gc, src, points, widths, n, sorted);
937
uxa_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
938
int srcx, int srcy, int w, int h, int dstx, int dsty,
939
unsigned long bitPlane)
941
ScreenPtr screen = pDst->pScreen;
942
uxa_screen_t *uxa_screen = uxa_get_screen(screen);
944
if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
948
if (uxa_prepare_access(pDst, UXA_GLAMOR_ACCESS_RW)) {
949
if (uxa_prepare_access(pSrc, UXA_GLAMOR_ACCESS_RO)) {
950
ok = glamor_copy_plane_nf(pSrc, pDst, pGC, srcx, srcy, w, h,
951
dstx, dsty, bitPlane, ®ion);
952
uxa_finish_access(pSrc, UXA_GLAMOR_ACCESS_RO);
954
uxa_finish_access(pDst, UXA_GLAMOR_ACCESS_RW);
962
return uxa_check_copy_plane(pSrc, pDst, pGC, srcx, srcy, w, h,
963
dstx, dsty, bitPlane);
967
uxa_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
968
int x, int y, unsigned int nglyph,
969
CharInfoPtr * ppci, pointer pglyphBase)
971
ScreenPtr screen = pDrawable->pScreen;
972
uxa_screen_t *uxa_screen = uxa_get_screen(screen);
974
if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
977
if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
978
ok = glamor_image_glyph_blt_nf(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
979
uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
987
uxa_check_image_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
991
uxa_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
992
int x, int y, unsigned int nglyph,
993
CharInfoPtr * ppci, pointer pglyphBase)
995
ScreenPtr screen = pDrawable->pScreen;
996
uxa_screen_t *uxa_screen = uxa_get_screen(screen);
998
if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
1001
if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
1002
ok = glamor_poly_glyph_blt_nf(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
1003
uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
1011
uxa_check_poly_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
1015
uxa_push_pixels(GCPtr pGC, PixmapPtr pBitmap,
1016
DrawablePtr pDrawable, int w, int h, int x, int y)
1018
ScreenPtr screen = pDrawable->pScreen;
1019
uxa_screen_t *uxa_screen = uxa_get_screen(screen);
1021
if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
1024
if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
1025
if (uxa_prepare_access(&pBitmap->drawable, UXA_GLAMOR_ACCESS_RO)) {
1026
ok = glamor_push_pixels_nf(pGC, pBitmap, pDrawable, w, h, x, y);
1027
uxa_finish_access(&pBitmap->drawable, UXA_GLAMOR_ACCESS_RO);
1029
uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
1037
uxa_check_push_pixels(pGC, pBitmap, pDrawable, w, h, x, y);
1040
const GCOps uxa_ops = {
1058
uxa_image_glyph_blt,
1063
void uxa_copy_window(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
1067
PixmapPtr pPixmap = (*pWin->drawable.pScreen->GetWindowPixmap) (pWin);
1069
dx = ptOldOrg.x - pWin->drawable.x;
1070
dy = ptOldOrg.y - pWin->drawable.y;
1071
REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
1073
REGION_INIT(pWin->drawable.pScreen, &rgnDst, NullBox, 0);
1075
REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip,
1078
if (pPixmap->screen_x || pPixmap->screen_y)
1079
REGION_TRANSLATE(pWin->drawable.pScreen, &rgnDst,
1080
-pPixmap->screen_x, -pPixmap->screen_y);
1083
miCopyRegion(&pPixmap->drawable, &pPixmap->drawable,
1084
NULL, &rgnDst, dx, dy, uxa_copy_n_to_n, 0, NULL);
1086
REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
1090
uxa_fill_region_solid(DrawablePtr pDrawable,
1092
Pixel pixel, CARD32 planemask, CARD32 alu)
1094
ScreenPtr screen = pDrawable->pScreen;
1095
uxa_screen_t *uxa_screen = uxa_get_screen(screen);
1102
pixmap = uxa_get_offscreen_pixmap(pDrawable, &xoff, &yoff);
1106
REGION_TRANSLATE(screen, pRegion, xoff, yoff);
1108
nbox = REGION_NUM_RECTS(pRegion);
1109
pBox = REGION_RECTS(pRegion);
1111
if (uxa_screen->info->check_solid &&
1112
!uxa_screen->info->check_solid(&pixmap->drawable, alu, planemask))
1115
if (!uxa_screen->info->prepare_solid(pixmap, alu, planemask, pixel))
1119
uxa_screen->info->solid(pixmap,
1121
pBox->x2, pBox->y2);
1124
uxa_screen->info->done_solid(pixmap);
1128
REGION_TRANSLATE(screen, pRegion, -xoff, -yoff);
1132
/* Try to do an accelerated tile of the pTile into pRegion of pDrawable.
1133
* Based on fbFillRegionTiled(), fbTile().
1136
uxa_fill_region_tiled(DrawablePtr pDrawable,
1139
DDXPointPtr pPatOrg, CARD32 planemask, CARD32 alu)
1141
uxa_screen_t *uxa_screen = uxa_get_screen(pDrawable->pScreen);
1144
int tileWidth, tileHeight;
1145
int nbox = REGION_NUM_RECTS(pRegion);
1146
BoxPtr pBox = REGION_RECTS(pRegion);
1149
tileWidth = pTile->drawable.width;
1150
tileHeight = pTile->drawable.height;
1152
/* If we're filling with a solid color, grab it out and go to
1153
* FillRegionsolid, saving numerous copies.
1155
if (tileWidth == 1 && tileHeight == 1)
1156
return uxa_fill_region_solid(pDrawable, pRegion,
1157
uxa_get_pixmap_first_pixel(pTile),
1160
pPixmap = uxa_get_offscreen_pixmap(pDrawable, &xoff, &yoff);
1161
if (!pPixmap || !uxa_pixmap_is_offscreen(pTile))
1164
if (uxa_screen->info->check_copy &&
1165
!uxa_screen->info->check_copy(pTile, pPixmap, alu, planemask))
1168
REGION_TRANSLATE(pScreen, pRegion, xoff, yoff);
1170
if ((*uxa_screen->info->prepare_copy) (pTile, pPixmap, 1, 1, alu,
1173
int height = pBox->y2 - pBox->y1;
1174
int dstY = pBox->y1;
1177
modulus(dstY - yoff - pDrawable->y - pPatOrg->y,
1180
while (height > 0) {
1181
int width = pBox->x2 - pBox->x1;
1182
int dstX = pBox->x1;
1184
int h = tileHeight - tileY;
1190
modulus(dstX - xoff - pDrawable->x - pPatOrg->x,
1194
int w = tileWidth - tileX;
1199
(*uxa_screen->info->copy) (pPixmap,
1211
(*uxa_screen->info->done_copy) (pPixmap);
1217
REGION_TRANSLATE(pScreen, pRegion, -xoff, -yoff);
1223
* Accelerates GetImage for solid ZPixmap downloads from framebuffer memory.
1225
* This is probably the only case we actually care about. The rest fall through
1226
* to migration and fbGetImage, which hopefully will result in migration pushing
1227
* the pixmap out of framebuffer.
1230
uxa_get_image(DrawablePtr pDrawable, int x, int y, int w, int h,
1231
unsigned int format, unsigned long planeMask, char *d)
1233
ScreenPtr screen = pDrawable->pScreen;
1234
uxa_screen_t *uxa_screen = uxa_get_screen(screen);
1236
PixmapPtr pPix = uxa_get_drawable_pixmap(pDrawable);
1240
uxa_get_drawable_deltas(pDrawable, pPix, &xoff, &yoff);
1242
Box.x1 = pDrawable->y + x + xoff;
1243
Box.y1 = pDrawable->y + y + yoff;
1244
Box.x2 = Box.x1 + w;
1245
Box.y2 = Box.y1 + h;
1247
if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
1249
if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
1250
ok = glamor_get_image_nf(pDrawable, x, y, w, h,
1251
format, planeMask, d);
1252
uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
1261
if (uxa_screen->force_fallback)
1264
pPix = uxa_get_offscreen_pixmap(pDrawable, &xoff, &yoff);
1266
if (pPix == NULL || uxa_screen->info->get_image == NULL)
1269
/* Only cover the ZPixmap, solid copy case. */
1270
if (format != ZPixmap || !UXA_PM_IS_SOLID(pDrawable, planeMask))
1273
/* Only try to handle the 8bpp and up cases, since we don't want to
1274
* think about <8bpp.
1276
if (pDrawable->bitsPerPixel < 8)
1279
ok = uxa_screen->info->get_image(pPix, pDrawable->x + x + xoff,
1280
pDrawable->y + y + yoff, w, h, d,
1281
PixmapBytePad(w, pDrawable->depth));
1286
UXA_FALLBACK(("from %p (%c)\n", pDrawable,
1287
uxa_drawable_location(pDrawable)));
1289
if (uxa_prepare_access(pDrawable, UXA_ACCESS_RO)) {
1290
fbGetImage(pDrawable, x, y, w, h, format, planeMask, d);
1291
uxa_finish_access(pDrawable, UXA_ACCESS_RO);