LCOV - code coverage report
Current view: top level - vcl/source/outdev - pixel.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 44 80 55.0 %
Date: 2015-06-13 12:38:46 Functions: 5 7 71.4 %
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             : #include <sal/types.h>
      20             : 
      21             : #include <boost/scoped_array.hpp>
      22             : #include <vcl/outdev.hxx>
      23             : #include <vcl/virdev.hxx>
      24             : #include <vcl/window.hxx>
      25             : 
      26             : #include "outdata.hxx"
      27             : #include "salgdi.hxx"
      28             : 
      29             : extern const sal_uLong nVCLRLut[ 6 ];
      30             : extern const sal_uLong nVCLGLut[ 6 ];
      31             : extern const sal_uLong nVCLBLut[ 6 ];
      32             : extern const sal_uLong nVCLDitherLut[ 256 ];
      33             : extern const sal_uLong nVCLLut[ 256 ];
      34             : 
      35           4 : Color OutputDevice::GetPixel( const Point& rPt ) const
      36             : {
      37             : 
      38           4 :     Color aColor;
      39             : 
      40           4 :     if ( mpGraphics || AcquireGraphics() )
      41             :     {
      42           4 :         if ( mbInitClipRegion )
      43           0 :             const_cast<OutputDevice*>(this)->InitClipRegion();
      44             : 
      45           4 :         if ( !mbOutputClipped )
      46             :         {
      47           4 :             const long nX = ImplLogicXToDevicePixel( rPt.X() );
      48           4 :             const long nY = ImplLogicYToDevicePixel( rPt.Y() );
      49           4 :             const SalColor aSalCol = mpGraphics->GetPixel( nX, nY, this );
      50           4 :             aColor.SetRed( SALCOLOR_RED( aSalCol ) );
      51           4 :             aColor.SetGreen( SALCOLOR_GREEN( aSalCol ) );
      52           4 :             aColor.SetBlue( SALCOLOR_BLUE( aSalCol ) );
      53             :         }
      54             :     }
      55           4 :     return aColor;
      56             : }
      57             : 
      58       68005 : void OutputDevice::DrawPixel( const Point& rPt )
      59             : {
      60       68005 :     assert_if_double_buffered_window();
      61             : 
      62       68005 :     if ( mpMetaFile )
      63        4150 :         mpMetaFile->AddAction( new MetaPointAction( rPt ) );
      64             : 
      65       68005 :     if ( !IsDeviceOutputNecessary() || !mbLineColor || ImplIsRecordLayout() )
      66        4211 :         return;
      67             : 
      68       68005 :     Point aPt = ImplLogicToDevicePixel( rPt );
      69             : 
      70       68005 :     if ( !mpGraphics && !AcquireGraphics() )
      71           0 :         return;
      72             : 
      73       68005 :     if ( mbInitClipRegion )
      74        5373 :         InitClipRegion();
      75             : 
      76       68005 :     if ( mbOutputClipped )
      77        4211 :         return;
      78             : 
      79       63794 :     if ( mbInitLineColor )
      80       60532 :         InitLineColor();
      81             : 
      82       63794 :     mpGraphics->DrawPixel( aPt.X(), aPt.Y(), this );
      83             : 
      84       63794 :     if( mpAlphaVDev )
      85        4094 :         mpAlphaVDev->DrawPixel( rPt );
      86             : }
      87             : 
      88      403061 : void OutputDevice::DrawPixel( const Point& rPt, const Color& rColor )
      89             : {
      90      403061 :     assert_if_double_buffered_window();
      91             : 
      92      403061 :     Color aColor = ImplDrawModeToColor( rColor );
      93             : 
      94      403061 :     if ( mpMetaFile )
      95         104 :         mpMetaFile->AddAction( new MetaPixelAction( rPt, aColor ) );
      96             : 
      97      403061 :     if ( !IsDeviceOutputNecessary() || ImplIsColorTransparent( aColor ) || ImplIsRecordLayout() )
      98         208 :         return;
      99             : 
     100      402957 :     Point aPt = ImplLogicToDevicePixel( rPt );
     101             : 
     102      402957 :     if ( !mpGraphics && !AcquireGraphics() )
     103           0 :         return;
     104             : 
     105      402957 :     if ( mbInitClipRegion )
     106       11493 :         InitClipRegion();
     107             : 
     108      402957 :     if ( mbOutputClipped )
     109           0 :         return;
     110             : 
     111      402957 :     mpGraphics->DrawPixel( aPt.X(), aPt.Y(), ImplColorToSal( aColor ), this );
     112             : 
     113      402957 :     if( mpAlphaVDev )
     114           0 :         mpAlphaVDev->DrawPixel( rPt );
     115             : }
     116             : 
     117           0 : void OutputDevice::DrawPixel( const Polygon& rPts, const Color* pColors )
     118             : {
     119           0 :     assert_if_double_buffered_window();
     120             : 
     121           0 :     if ( !pColors )
     122             :     {
     123           0 :         DrawPixel( rPts, GetLineColor() );
     124             :     }
     125             :     else
     126             :     {
     127             :         DBG_ASSERT( pColors, "OutputDevice::DrawPixel: No color array specified" );
     128             : 
     129           0 :         const sal_uInt16 nSize = rPts.GetSize();
     130             : 
     131           0 :         if ( nSize )
     132             :         {
     133           0 :             if ( mpMetaFile )
     134             :             {
     135           0 :                 for ( sal_uInt16 i = 0; i < nSize; i++ )
     136             :                 {
     137           0 :                     mpMetaFile->AddAction( new MetaPixelAction( rPts[ i ], pColors[ i ] ) );
     138             :                 }
     139             :             }
     140           0 :             if ( !IsDeviceOutputNecessary() || ImplIsRecordLayout() )
     141           0 :                 return;
     142             : 
     143           0 :             if ( mpGraphics || AcquireGraphics() )
     144             :             {
     145           0 :                 if ( mbInitClipRegion )
     146           0 :                     InitClipRegion();
     147             : 
     148           0 :                 if ( mbOutputClipped )
     149           0 :                     return;
     150             : 
     151           0 :                 for ( sal_uInt16 i = 0; i < nSize; i++ )
     152             :                 {
     153           0 :                     const Point aPt( ImplLogicToDevicePixel( rPts[ i ] ) );
     154           0 :                     mpGraphics->DrawPixel( aPt.X(), aPt.Y(), ImplColorToSal( pColors[ i ] ), this );
     155             :                 }
     156             :             }
     157             :         }
     158             :     }
     159             : 
     160           0 :     if( mpAlphaVDev )
     161           0 :         mpAlphaVDev->DrawPixel( rPts, pColors );
     162             : }
     163             : 
     164           0 : void OutputDevice::DrawPixel( const Polygon& rPts, const Color& rColor )
     165             : {
     166           0 :     assert_if_double_buffered_window();
     167             : 
     168           0 :     if( rColor != COL_TRANSPARENT && ! ImplIsRecordLayout() )
     169             :     {
     170           0 :         const sal_uInt16 nSize = rPts.GetSize();
     171           0 :         boost::scoped_array<Color> pColArray(new Color[ nSize ]);
     172             : 
     173           0 :         for( sal_uInt16 i = 0; i < nSize; i++ )
     174             :         {
     175           0 :             pColArray[ i ] = rColor;
     176             :         }
     177           0 :         DrawPixel( rPts, pColArray.get() );
     178             :     }
     179             : 
     180           0 :     if( mpAlphaVDev )
     181           0 :         mpAlphaVDev->DrawPixel( rPts, rColor );
     182         801 : }
     183             : 
     184             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11