LCOV - code coverage report
Current view: top level - vcl/unx/generic/gdi - x11cairotextrender.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 32 48 66.7 %
Date: 2015-06-13 12:38:46 Functions: 8 10 80.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "x11cairotextrender.hxx"
      21             : #include "unx/saldata.hxx"
      22             : #include "unx/saldisp.hxx"
      23             : #include "unx/salvd.h"
      24             : 
      25             : #include "gcach_xpeer.hxx"
      26             : 
      27             : #include <cairo.h>
      28             : #include <cairo-ft.h>
      29             : 
      30             : #include <cairo-xlib.h>
      31             : #include <cairo-xlib-xrender.h>
      32             : 
      33             : struct BOX
      34             : {
      35             :     short x1, x2, y1, y2;
      36             : };
      37             : struct _XRegion
      38             : {
      39             :     long size;
      40             :     long numRects;
      41             :     BOX *rects;
      42             :     BOX extents;
      43             : };
      44             : 
      45         208 : X11CairoTextRender::X11CairoTextRender(X11SalGraphics& rParent)
      46         208 :     : mrParent(rParent)
      47             : {
      48         208 : }
      49             : 
      50           3 : GlyphCache& X11CairoTextRender::getPlatformGlyphCache()
      51             : {
      52           3 :     return X11GlyphCache::GetInstance();
      53             : }
      54             : 
      55           3 : cairo_t* X11CairoTextRender::getCairoContext()
      56             : {
      57             :     // find a XRenderPictFormat compatible with the Drawable
      58           3 :     XRenderPictFormat* pVisualFormat = mrParent.GetXRenderFormat();
      59             : 
      60           3 :     Display* pDisplay = mrParent.GetXDisplay();
      61             : 
      62           3 :     cairo_surface_t* surface = NULL;
      63           3 :     if (pVisualFormat)
      64             :     {
      65             :         surface = cairo_xlib_surface_create_with_xrender_format (
      66             :                         pDisplay, mrParent.hDrawable_,
      67           3 :                         ScreenOfDisplay(pDisplay, mrParent.m_nXScreen.getXScreen()),
      68           6 :                         pVisualFormat, SAL_MAX_INT16, SAL_MAX_INT16);
      69             :     }
      70             :     else
      71             :     {
      72             :         surface = cairo_xlib_surface_create(pDisplay, mrParent.hDrawable_,
      73           0 :             mrParent.GetVisual().visual, SAL_MAX_INT16, SAL_MAX_INT16);
      74             :     }
      75             : 
      76           3 :     if (!surface)
      77           0 :         return NULL;
      78             : 
      79           3 :     cairo_t *cr = cairo_create(surface);
      80           3 :     cairo_surface_destroy(surface);
      81           3 :     return cr;
      82             : }
      83             : 
      84           3 : void X11CairoTextRender::getSurfaceOffset( double& nDX, double& nDY )
      85             : {
      86           3 :     nDX = 0;
      87           3 :     nDY = 0;
      88           3 : }
      89             : 
      90           3 : void X11CairoTextRender::clipRegion(cairo_t* cr)
      91             : {
      92           3 :     Region pClipRegion = mrParent.mpClipRegion;
      93           3 :     if( pClipRegion && !XEmptyRegion( pClipRegion ) )
      94             :     {
      95           6 :         for (long i = 0; i < pClipRegion->numRects; ++i)
      96             :         {
      97             :             cairo_rectangle(cr,
      98           3 :                 pClipRegion->rects[i].x1,
      99           3 :                 pClipRegion->rects[i].y1,
     100           3 :                 pClipRegion->rects[i].x2 - pClipRegion->rects[i].x1,
     101          12 :                 pClipRegion->rects[i].y2 - pClipRegion->rects[i].y1);
     102             :         }
     103           3 :         cairo_clip(cr);
     104             :     }
     105           3 : }
     106             : 
     107           0 : size_t X11CairoTextRender::GetWidth() const
     108             : {
     109           0 :     SalGeometryProvider *pProvider = mrParent.m_pFrame;
     110           0 :     if( !pProvider )
     111           0 :         pProvider = mrParent.m_pVDev;
     112             : 
     113           0 :     if( pProvider )
     114           0 :         return pProvider->GetWidth();
     115             :     else
     116           0 :         return 1;
     117             : }
     118             : 
     119           0 : size_t X11CairoTextRender::GetHeight() const
     120             : {
     121           0 :     SalGeometryProvider *pProvider = mrParent.m_pFrame;
     122           0 :     if( !pProvider )
     123           0 :         pProvider = mrParent.m_pVDev;
     124             : 
     125           0 :     if( pProvider )
     126           0 :         return pProvider->GetHeight();
     127             :     else
     128           0 :         return 1;
     129             : }
     130             : 
     131           3 : void X11CairoTextRender::drawSurface(cairo_t* /*cr*/)
     132             : {
     133          12 : }
     134             : 
     135             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11