~ubuntu-branches/ubuntu/raring/xserver-xorg-video-intel/raring

« back to all changes in this revision

Viewing changes to src/sna/sna_accel.c

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2012-09-29 16:45:35 UTC
  • mfrom: (1.4.24)
  • Revision ID: package-import@ubuntu.com-20120929164535-g15mwstkty0de7ki
Tags: 2:2.20.9-0ubuntu1
* Merge from unrelease debian git.
  - fixes racy UXA pageflip code (LP: #966744)
* Drop dont-run-intel-mode-fini-before-preinit.diff, upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2571
2571
        int16_t dx, dy;
2572
2572
        int ret;
2573
2573
 
2574
 
        DBG(("%s pixmap=%ld, box=((%d, %d), (%d, %d)), flagss=%x...\n",
 
2574
        DBG(("%s pixmap=%ld, box=((%d, %d), (%d, %d)), flags=%x...\n",
2575
2575
             __FUNCTION__,
2576
2576
             pixmap->drawable.serialNumber,
2577
2577
             box->x1, box->y1, box->x2, box->y2,
3178
3178
        DBG(("%s, changes=%lx\n", __FUNCTION__, changes));
3179
3179
 
3180
3180
        assert(gc->ops == (GCOps *)&sna_gc_ops);
3181
 
        assert(gc->funcs == (GCFuncs *)&sna_gc_funcs);
 
3181
        gc->ops = (GCOps *)&sna_gc_ops__cpu;
 
3182
 
 
3183
        sgc->old_funcs = gc->funcs;
 
3184
        gc->funcs = (GCFuncs *)&sna_gc_funcs__cpu;
3182
3185
 
3183
3186
        sgc->priv = gc->pCompositeClip;
3184
3187
        gc->pCompositeClip = region;
3185
 
        gc->ops = (GCOps *)&sna_gc_ops__cpu;
3186
 
        gc->funcs = (GCFuncs *)&sna_gc_funcs__cpu;
3187
3188
 
3188
3189
        if (gc->clientClipType == CT_PIXMAP) {
3189
3190
                PixmapPtr clip = gc->clientClip;
3238
3239
        assert(gc->funcs == (GCFuncs *)&sna_gc_funcs__cpu);
3239
3240
 
3240
3241
        gc->ops = (GCOps *)&sna_gc_ops;
3241
 
        gc->funcs = (GCFuncs *)&sna_gc_funcs;
 
3242
        gc->funcs = sna_gc(gc)->old_funcs;
3242
3243
        gc->pCompositeClip = sna_gc(gc)->priv;
3243
3244
}
3244
3245
 
3332
3333
        return v;
3333
3334
}
3334
3335
 
 
3336
static int16_t clamp(int16_t a, int16_t b)
 
3337
{
 
3338
        int v = (int)a + (int)b;
 
3339
        if (v > MAXSHORT)
 
3340
                return MAXSHORT;
 
3341
        if (v < MINSHORT)
 
3342
                return MINSHORT;
 
3343
        return v;
 
3344
}
 
3345
 
3335
3346
static inline bool box32_to_box16(const Box32Rec *b32, BoxRec *b16)
3336
3347
{
3337
3348
        b16->x1 = b32->x1;
4867
4878
 
4868
4879
        region.extents.x1 = dx;
4869
4880
        region.extents.y1 = dy;
4870
 
        region.extents.x2 = dx + width;
4871
 
        region.extents.y2 = dy + height;
 
4881
        region.extents.x2 = bound(dx, width);
 
4882
        region.extents.y2 = bound(dy, height);
4872
4883
        region.data = NULL;
4873
4884
 
4874
4885
        DBG(("%s: dst extents (%d, %d), (%d, %d)\n", __FUNCTION__,
4880
4891
                return NULL;
4881
4892
        }
4882
4893
 
4883
 
        region.extents.x1 += sx - dx;
4884
 
        region.extents.x2 += sx - dx;
4885
 
        region.extents.y1 += sy - dy;
4886
 
        region.extents.y2 += sy - dy;
 
4894
        region.extents.x1 = clamp(region.extents.x1, sx - dx);
 
4895
        region.extents.x2 = clamp(region.extents.x2, sx - dx);
 
4896
        region.extents.y1 = clamp(region.extents.y1, sy - dy);
 
4897
        region.extents.y2 = clamp(region.extents.y2, sy - dy);
4887
4898
 
4888
4899
        /* Compute source clip region */
4889
4900
        clip = NULL;
5281
5292
                        b->y2 = b->y1 + 1;
5282
5293
                        DBG(("%s: (%d, %d), (%d, %d)\n",
5283
5294
                             __FUNCTION__, b->x1, b->y1, b->x2, b->y2));
 
5295
                        assert(b->x1 >= drawable->x);
 
5296
                        assert(b->x2 <= drawable->x + drawable->width);
 
5297
                        assert(b->y1 >= drawable->y);
 
5298
                        assert(b->y2 <= drawable->y + drawable->height);
5284
5299
                        if (b->x2 > b->x1) {
5285
5300
                                if (b != box &&
5286
5301
                                    b->y1 == b[-1].y2 &&
12552
12567
        long unsigned i, n;
12553
12568
        uint32_t fg;
12554
12569
 
12555
 
        if (drawable->depth < 8)
12556
 
                goto fallback;
12557
 
 
12558
12570
        for (i = n = 0; i < count; i++) {
12559
12571
                if (sna_get_glyph8(gc->font, priv, chars[i], &info[n]))
12560
12572
                        n++;
12579
12591
                return x + extents.overallRight;
12580
12592
 
12581
12593
        if (FORCE_FALLBACK)
12582
 
                goto force_fallback;
 
12594
                goto fallback;
12583
12595
 
12584
12596
        if (!ACCEL_POLY_TEXT8)
12585
 
                goto force_fallback;
 
12597
                goto fallback;
12586
12598
 
12587
12599
        if (sna_font_too_large(gc->font))
12588
 
                goto force_fallback;
 
12600
                goto fallback;
12589
12601
 
12590
12602
        if (!PM_IS_SOLID(drawable, gc->planemask))
12591
 
                goto force_fallback;
 
12603
                goto fallback;
12592
12604
 
12593
12605
        if (!gc_is_solid(gc, &fg))
12594
 
                goto force_fallback;
 
12606
                goto fallback;
12595
12607
 
12596
12608
        if (!sna_glyph_blt(drawable, gc, x, y, n, info, &region, fg, -1, true)) {
12597
 
force_fallback:
 
12609
fallback:
12598
12610
                DBG(("%s: fallback\n", __FUNCTION__));
12599
12611
                gc->font->get_glyphs(gc->font, count, (unsigned char *)chars,
12600
12612
                                     Linear8Bit, &n, info);
12615
12627
out:
12616
12628
        RegionUninit(&region);
12617
12629
        return x + extents.overallRight;
12618
 
 
12619
 
fallback:
12620
 
        DBG(("%s: fallback -- depth=%d\n", __FUNCTION__, drawable->depth));
12621
 
        gc->font->get_glyphs(gc->font, count, (unsigned char *)chars,
12622
 
                             Linear8Bit, &n, info);
12623
 
        if (n == 0)
12624
 
                return x;
12625
 
 
12626
 
        extents.overallWidth = x;
12627
 
        for (i = 0; i < n; i++)
12628
 
                extents.overallWidth += info[i]->metrics.characterWidth;
12629
 
 
12630
 
        DBG(("%s: fallback -- fbPolyGlyphBlt\n", __FUNCTION__));
12631
 
        fbPolyGlyphBlt(drawable, gc, x, y, n, info, FONTGLYPHS(gc->font));
12632
 
 
12633
 
        return extents.overallWidth;
12634
12630
}
12635
12631
 
12636
12632
static int
12645
12641
        long unsigned i, n;
12646
12642
        uint32_t fg;
12647
12643
 
12648
 
        if (drawable->depth < 8)
12649
 
                goto fallback;
12650
 
 
12651
12644
        for (i = n = 0; i < count; i++) {
12652
12645
                if (sna_get_glyph16(gc->font, priv, chars[i], &info[n]))
12653
12646
                        n++;
12672
12665
                return x + extents.overallRight;
12673
12666
 
12674
12667
        if (FORCE_FALLBACK)
12675
 
                goto force_fallback;
 
12668
                goto fallback;
12676
12669
 
12677
12670
        if (!ACCEL_POLY_TEXT16)
12678
 
                goto force_fallback;
 
12671
                goto fallback;
12679
12672
 
12680
12673
        if (sna_font_too_large(gc->font))
12681
 
                goto force_fallback;
 
12674
                goto fallback;
12682
12675
 
12683
12676
        if (!PM_IS_SOLID(drawable, gc->planemask))
12684
 
                goto force_fallback;
 
12677
                goto fallback;
12685
12678
 
12686
12679
        if (!gc_is_solid(gc, &fg))
12687
 
                goto force_fallback;
 
12680
                goto fallback;
12688
12681
 
12689
12682
        if (!sna_glyph_blt(drawable, gc, x, y, n, info, &region, fg, -1, true)) {
12690
 
force_fallback:
 
12683
fallback:
12691
12684
                DBG(("%s: fallback\n", __FUNCTION__));
12692
12685
                gc->font->get_glyphs(gc->font, count, (unsigned char *)chars,
12693
12686
                                     FONTLASTROW(gc->font) ? TwoD16Bit : Linear16Bit,
12709
12702
out:
12710
12703
        RegionUninit(&region);
12711
12704
        return x + extents.overallRight;
12712
 
 
12713
 
fallback:
12714
 
        DBG(("%s: fallback -- depth=%d\n", __FUNCTION__, drawable->depth));
12715
 
        gc->font->get_glyphs(gc->font, count, (unsigned char *)chars,
12716
 
                             FONTLASTROW(gc->font) ? TwoD16Bit : Linear16Bit,
12717
 
                             &n, info);
12718
 
        if (n == 0)
12719
 
                return x;
12720
 
 
12721
 
        extents.overallWidth = x;
12722
 
        for (i = 0; i < n; i++)
12723
 
                extents.overallWidth += info[i]->metrics.characterWidth;
12724
 
 
12725
 
        DBG(("%s: fallback -- fbPolyGlyphBlt\n", __FUNCTION__));
12726
 
        fbPolyGlyphBlt(drawable, gc, x, y, n, info, FONTGLYPHS(gc->font));
12727
 
 
12728
 
        return extents.overallWidth;
12729
12705
}
12730
12706
 
12731
12707
static void
12739
12715
        RegionRec region;
12740
12716
        long unsigned i, n;
12741
12717
 
12742
 
        if (drawable->depth < 8)
12743
 
                goto fallback;
12744
 
 
12745
12718
        for (i = n = 0; i < count; i++) {
12746
12719
                if (sna_get_glyph8(gc->font, priv, chars[i], &info[n]))
12747
12720
                        n++;
12778
12751
             region.extents.x2, region.extents.y2));
12779
12752
 
12780
12753
        if (FORCE_FALLBACK)
12781
 
                goto force_fallback;
 
12754
                goto fallback;
12782
12755
 
12783
12756
        if (!ACCEL_IMAGE_TEXT8)
12784
 
                goto force_fallback;
 
12757
                goto fallback;
12785
12758
 
12786
12759
        if (sna_font_too_large(gc->font))
12787
 
                goto force_fallback;
 
12760
                goto fallback;
12788
12761
 
12789
12762
        if (!PM_IS_SOLID(drawable, gc->planemask))
12790
 
                goto force_fallback;
 
12763
                goto fallback;
12791
12764
 
12792
12765
        if (!sna_glyph_blt(drawable, gc, x, y, n, info, &region,
12793
12766
                           gc->fgPixel, gc->bgPixel, false)) {
12794
 
force_fallback:
 
12767
fallback:
12795
12768
                DBG(("%s: fallback\n", __FUNCTION__));
12796
12769
                gc->font->get_glyphs(gc->font, count, (unsigned char *)chars,
12797
12770
                                     Linear8Bit, &n, info);
12811
12784
        }
12812
12785
out:
12813
12786
        RegionUninit(&region);
12814
 
        return;
12815
 
 
12816
 
fallback:
12817
 
        DBG(("%s: fallback, depth=%d\n", __FUNCTION__, drawable->depth));
12818
 
        gc->font->get_glyphs(gc->font, count, (unsigned char *)chars,
12819
 
                             Linear8Bit, &n, info);
12820
 
        if (n) {
12821
 
                DBG(("%s: fallback -- fbImageGlyphBlt\n", __FUNCTION__));
12822
 
                fbImageGlyphBlt(drawable, gc, x, y, n, info, FONTGLYPHS(gc->font));
12823
 
        }
12824
12787
}
12825
12788
 
12826
12789
static void
12834
12797
        RegionRec region;
12835
12798
        long unsigned i, n;
12836
12799
 
12837
 
        if (drawable->depth < 8)
12838
 
                goto fallback;
12839
 
 
12840
12800
        for (i = n = 0; i < count; i++) {
12841
12801
                if (sna_get_glyph16(gc->font, priv, chars[i], &info[n]))
12842
12802
                        n++;
12873
12833
             region.extents.x2, region.extents.y2));
12874
12834
 
12875
12835
        if (FORCE_FALLBACK)
12876
 
                goto force_fallback;
 
12836
                goto fallback;
12877
12837
 
12878
12838
        if (!ACCEL_IMAGE_TEXT16)
12879
 
                goto force_fallback;
 
12839
                goto fallback;
12880
12840
 
12881
12841
        if (sna_font_too_large(gc->font))
12882
 
                goto force_fallback;
 
12842
                goto fallback;
12883
12843
 
12884
12844
        if (!PM_IS_SOLID(drawable, gc->planemask))
12885
 
                goto force_fallback;
 
12845
                goto fallback;
12886
12846
 
12887
12847
        if (!sna_glyph_blt(drawable, gc, x, y, n, info, &region,
12888
12848
                           gc->fgPixel, gc->bgPixel, false)) {
12889
 
force_fallback:
 
12849
fallback:
12890
12850
                DBG(("%s: fallback\n", __FUNCTION__));
12891
12851
                gc->font->get_glyphs(gc->font, count, (unsigned char *)chars,
12892
12852
                                     FONTLASTROW(gc->font) ? TwoD16Bit : Linear16Bit,
12907
12867
        }
12908
12868
out:
12909
12869
        RegionUninit(&region);
12910
 
        return;
12911
 
 
12912
 
fallback:
12913
 
        DBG(("%s: fallback -- depth=%d\n", __FUNCTION__, drawable->depth));
12914
 
        gc->font->get_glyphs(gc->font, count, (unsigned char *)chars,
12915
 
                             FONTLASTROW(gc->font) ? TwoD16Bit : Linear16Bit,
12916
 
                             &n, info);
12917
 
        if (n) {
12918
 
                DBG(("%s: fallback -- fbImageGlyphBlt\n", __FUNCTION__));
12919
 
                fbImageGlyphBlt(drawable, gc, x, y, n, info, FONTGLYPHS(gc->font));
12920
 
        }
12921
12870
}
12922
12871
 
12923
12872
/* XXX Damage bypasses the Text interface and so we lose our custom gluphs */
13754
13703
                             priv->pixmap->drawable.serialNumber));
13755
13704
                        ret = sna_pixmap_move_to_cpu(priv->pixmap,
13756
13705
                                                     MOVE_READ | MOVE_WRITE);
 
13706
                        assert(!ret || priv->gpu_bo == NULL);
13757
13707
                        if (priv->pixmap->refcnt == 0)
13758
13708
                                __sna_free_pixmap(sna, priv->pixmap, priv);
13759
13709
                } else {