View | Details | Raw Unified | Return to issue 85470
Collapse All | Expand All

(-)vcl.precairo/inc/vcl/glyphcache.hxx (+3 lines)
Lines 210-215 Link Here
210
    int                         GetExtInfo() { return mnExtInfo; }
210
    int                         GetExtInfo() { return mnExtInfo; }
211
    void*                       GetExtPointer() { return mpExtData; }
211
    void*                       GetExtPointer() { return mpExtData; }
212
212
213
    virtual void*               GetFtFace() const { return 0; }
214
    virtual int                 GetLoadFlags() const { return 0; }
215
213
protected:
216
protected:
214
    friend class GlyphCache;
217
    friend class GlyphCache;
215
    friend class ServerFontLayout;
218
    friend class ServerFontLayout;
(-)vcl.precairo/source/glyphs/gcach_ftyp.hxx (+3 lines)
Lines 200-205 Link Here
200
    int                         GetEmUnits() const;
200
    int                         GetEmUnits() const;
201
    const FT_Size_Metrics&      GetMetricsFT() const { return maSizeFT->metrics; }
201
    const FT_Size_Metrics&      GetMetricsFT() const { return maSizeFT->metrics; }
202
202
203
    virtual void*               GetFtFace() const { return maFaceFT; }
204
    virtual int               	GetLoadFlags() const { return mnLoadFlags; }
205
203
protected:
206
protected:
204
    friend class GlyphCache;
207
    friend class GlyphCache;
205
208
(-)vcl.precairo/unx/source/gdi/salgdi3.cxx (-7 / +203 lines)
Lines 123-128 Link Here
123
123
124
#include <hash_set>
124
#include <hash_set>
125
125
126
struct cairo_surface_t;
127
struct cairo_t;
128
struct cairo_font_face_t;
129
typedef void* FT_Face;
130
struct cairo_matrix_t {
131
    double xx; double yx;
132
    double xy; double yy;
133
    double x0; double y0;
134
};
135
struct cairo_glyph_t
136
{
137
    unsigned long index;
138
    double x;
139
    double y;
140
};
141
126
using namespace rtl;
142
using namespace rtl;
127
143
128
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
144
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Lines 735-740 Link Here
735
751
736
//--------------------------------------------------------------------------
752
//--------------------------------------------------------------------------
737
753
754
class CairoWrapper
755
{
756
private:
757
    bool mbIsValid;
758
759
    cairo_surface_t* (*mp_xlib_surface_create)(Display *, Drawable , Visual *, int , int );
760
    void (*mp_surface_destroy)(cairo_surface_t *);
761
    cairo_t* (*mp_create)(cairo_surface_t *);
762
    void (*mp_destroy)(cairo_t*);
763
    cairo_font_face_t * (*mp_ft_font_face_create_for_ft_face)(FT_Face, int);
764
    void (*mp_set_font_face)(cairo_t *, cairo_font_face_t *);
765
    void (*mp_font_face_destroy)(cairo_font_face_t *);
766
    void (*mp_matrix_init_scale)(cairo_matrix_t *, double, double);
767
    void (*mp_set_font_matrix)(cairo_t *, const cairo_matrix_t *);
768
    void (*mp_show_glyphs)(cairo_t *, const cairo_glyph_t *, int );
769
770
    oslGenericFunction loadSymbol( const char* );
771
    CairoWrapper();
772
public:
773
    static CairoWrapper& get();
774
    bool isValid() const { return mbIsValid; }
775
776
    cairo_surface_t* xlib_surface_create(Display *pDisplay, Drawable drawable, Visual *pVisual, int width, int height)
777
        { return (*mp_xlib_surface_create)(pDisplay, drawable, pVisual, width, height); }
778
    void surface_destroy(cairo_surface_t *surface) { (*mp_surface_destroy)(surface); }
779
    cairo_t* create(cairo_surface_t *surface) { return (*mp_create)(surface); }
780
    void destroy(cairo_t *cr) { (*mp_destroy)(cr); }
781
    cairo_font_face_t* ft_font_face_create_for_ft_face(FT_Face face, int load_flags)
782
        { return (*mp_ft_font_face_create_for_ft_face)(face, load_flags); }
783
    void set_font_face(cairo_t *cr, cairo_font_face_t *font_face)
784
        { (*mp_set_font_face)(cr, font_face); }
785
    void font_face_destroy(cairo_font_face_t *font_face)
786
        { (*mp_font_face_destroy)(font_face); }
787
    void matrix_init_scale(cairo_matrix_t *matrix, double sx, double sy)
788
        { (*mp_matrix_init_scale)(matrix, sx, sy); }
789
    void set_font_matrix(cairo_t *cr, const cairo_matrix_t *matrix)
790
        { (*mp_set_font_matrix)(cr, matrix); }
791
    void show_glyphs(cairo_t *cr, const cairo_glyph_t *glyphs, int no_glyphs)
792
        { (*mp_show_glyphs)(cr, glyphs, no_glyphs); }
793
};
794
795
static CairoWrapper* pOneInstance = NULL;
796
797
CairoWrapper& CairoWrapper::get()
798
{
799
    if( ! pOneInstance )
800
        pOneInstance = new CairoWrapper();
801
    return *pOneInstance;
802
}
803
804
oslGenericFunction CairoWrapper::loadSymbol( const char* pSymbol )
805
{
806
    OUString aSym( OUString::createFromAscii( pSymbol ) );
807
    oslGenericFunction pSym = osl_getFunctionSymbol( NULL, aSym.pData );
808
#if OSL_DEBUG_LEVEL > 1
809
    fprintf( stderr, "%s %s\n", pSymbol, pSym ? "found" : "not found" );
810
#endif
811
    return pSym;
812
}
813
814
CairoWrapper::CairoWrapper() : mbIsValid(false)
815
{
816
    mp_xlib_surface_create = (cairo_surface_t* (*)(Display *, Drawable , Visual *, int , int )) 
817
        loadSymbol( "cairo_xlib_surface_create" );
818
    mp_surface_destroy = (void(*)(cairo_surface_t*)) 
819
        loadSymbol( "cairo_surface_destroy" );
820
    mp_create = (cairo_t*(*)(cairo_surface_t*)) 
821
        loadSymbol( "cairo_create" );
822
    mp_destroy = (void(*)(cairo_t*))
823
        loadSymbol( "cairo_destroy" );
824
    mp_ft_font_face_create_for_ft_face = (cairo_font_face_t * (*)(FT_Face, int))
825
        loadSymbol( "cairo_ft_font_face_create_for_ft_face" );
826
    mp_set_font_face = (void (*)(cairo_t *, cairo_font_face_t *))
827
        loadSymbol( "cairo_set_font_face" );
828
    mp_font_face_destroy = (void (*)(cairo_font_face_t *))
829
        loadSymbol( "cairo_font_face_destroy" );
830
    mp_matrix_init_scale = (void (*)(cairo_matrix_t *, double, double))
831
        loadSymbol( "cairo_matrix_init_scale" );
832
    mp_set_font_matrix = (void (*)(cairo_t *, const cairo_matrix_t *))
833
        loadSymbol( "cairo_set_font_matrix" );
834
    mp_show_glyphs = (void (*)(cairo_t *, const cairo_glyph_t *, int ))
835
        loadSymbol( "cairo_show_glyphs" );
836
837
    mbIsValid = 
838
        (
839
            mp_xlib_surface_create &&
840
            mp_surface_destroy &&
841
            mp_create &&
842
            mp_destroy &&
843
            mp_ft_font_face_create_for_ft_face &&
844
            mp_set_font_face &&
845
            mp_font_face_destroy &&
846
            mp_matrix_init_scale &&
847
            mp_set_font_matrix &&
848
            mp_show_glyphs
849
        );
850
    if (!mbIsValid)
851
    {
852
#if OSL_DEBUG_LEVEL > 1
853
        fprintf( stderr, "not all needed symbols were found in libfontconfig\n" );
854
#endif
855
    }
856
}
857
858
void DrawCairoAAFontString( const X11SalGraphics& rGraphics, const ServerFontLayout& rLayout )
859
{
860
    Display* pDisplay = rGraphics.GetXDisplay();
861
    Visual* pVisual = rGraphics.GetDisplay()->GetVisual( rGraphics.GetScreenNumber() ).GetVisual();
862
    Drawable hDrawable_ = rGraphics.GetDrawable();
863
    CairoWrapper &rCairo = CairoWrapper::get();
864
865
    //start temp
866
867
    int width, height;
868
    unsigned uDummy;
869
    XLIB_Window wDummy;
870
    unsigned int nDrawDepth;
871
    ::XGetGeometry( pDisplay, hDrawable_, &wDummy, &width, &height,
872
                  &uDummy, &uDummy, &uDummy, &nDrawDepth );
873
874
	width = height = 700;
875
876
    cairo_surface_t *surface = rCairo.xlib_surface_create (pDisplay,
877
	hDrawable_, pVisual, width, height);
878
    //end temp
879
880
    cairo_t *cr = rCairo.create (surface);
881
    rCairo.surface_destroy (surface);
882
883
//    cairo_set_source_rgb (cr, 1,0,0);
884
885
    ServerFont& rFont = rLayout.GetServerFont();
886
887
    cairo_font_face_t* font_face = 
888
        rCairo.ft_font_face_create_for_ft_face(rFont.GetFtFace(), rFont.GetLoadFlags());
889
890
    rCairo.set_font_face(cr, font_face);
891
892
    cairo_matrix_t m;
893
    const ImplFontSelectData& rFSD = rFont.GetFontSelData();
894
    int nWidth = rFSD.mnWidth ? rFSD.mnWidth : rFSD.mnHeight;
895
    rCairo.matrix_init_scale(&m, nWidth, rFSD.mnHeight);
896
    rCairo.set_font_matrix(cr, &m);
897
898
    Point aPos;
899
    std::vector<cairo_glyph_t> cairo_glyphs;
900
    for( int nStart = 0;;)
901
    {
902
	sal_Int32 nGlyph;
903
        int nGlyphs = rLayout.GetNextGlyphs( 1, &nGlyph, aPos, nStart );
904
        if( !nGlyphs )
905
            break;
906
907
        // #i51924# avoid 32->16bit coordinate truncation problem in X11
908
        // TODO: reevaluate once displays with >30000 pixels are available
909
        if( aPos.X() >= 30000 || aPos.Y() >= 30000 )
910
            continue;
911
912
        cairo_glyph_t aGlyph;
913
        aGlyph.index = nGlyph;
914
        aGlyph.x = aPos.X();
915
        aGlyph.y = aPos.Y();
916
        cairo_glyphs.push_back(aGlyph);
917
    }
918
919
    if (!cairo_glyphs.empty())
920
        rCairo.show_glyphs (cr, &cairo_glyphs[0], cairo_glyphs.size());
921
922
    rCairo.font_face_destroy(font_face);
923
924
    rCairo.destroy (cr);
925
}
926
927
//--------------------------------------------------------------------------
928
738
void X11SalGraphics::DrawServerAAFontString( const ServerFontLayout& rLayout )
929
void X11SalGraphics::DrawServerAAFontString( const ServerFontLayout& rLayout )
739
{
930
{
740
    Display* pDisplay = GetXDisplay();
931
    Display* pDisplay = GetXDisplay();
Lines 1111-1125 Link Here
1111
    // draw complex text
1302
    // draw complex text
1112
    ServerFont& rFont = rLayout.GetServerFont();
1303
    ServerFont& rFont = rLayout.GetServerFont();
1113
1304
1114
    X11GlyphPeer& rGlyphPeer = X11GlyphCache::GetInstance().GetPeer();
1305
    if (rFont.GetFtFace() && CairoWrapper::get().isValid())
1115
    if( rGlyphPeer.GetGlyphSet( rFont, m_nScreen ) )
1306
        DrawCairoAAFontString( *this, rLayout );
1116
        DrawServerAAFontString( rLayout );
1307
    else
1308
    {
1309
        X11GlyphPeer& rGlyphPeer = X11GlyphCache::GetInstance().GetPeer();
1310
        if( rGlyphPeer.GetGlyphSet( rFont, m_nScreen ) )
1311
            DrawServerAAFontString( rLayout );
1117
#ifndef MACOSX        /* ignore X11 fonts on MACOSX */
1312
#ifndef MACOSX        /* ignore X11 fonts on MACOSX */
1118
    else if( !rGlyphPeer.ForcedAntialiasing( rFont, m_nScreen ) )
1313
        else if( !rGlyphPeer.ForcedAntialiasing( rFont, m_nScreen ) )
1119
        DrawServerSimpleFontString( rLayout );
1314
            DrawServerSimpleFontString( rLayout );
1120
#endif // MACOSX
1315
#endif // MACOSX
1121
    else
1316
        else
1122
        DrawServerAAForcedString( rLayout );
1317
            DrawServerAAForcedString( rLayout );
1318
    }
1123
}
1319
}
1124
1320
1125
//--------------------------------------------------------------------------
1321
//--------------------------------------------------------------------------

Return to issue 85470