LCOV - code coverage report
Current view: top level - svx/source/sdr/primitive2d - sdrprimitivetools.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 28 28 100.0 %
Date: 2014-11-03 Functions: 3 3 100.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 <sdr/primitive2d/sdrprimitivetools.hxx>
      21             : #include <vcl/bmpacc.hxx>
      22             : #include <osl/mutex.hxx>
      23             : #include <vcl/lazydelete.hxx>
      24             : 
      25             : 
      26             : // helper methods
      27             : 
      28             : namespace drawinglayer
      29             : {
      30             :     namespace primitive2d
      31             :     {
      32        1250 :         BitmapEx createDefaultCross_3x3(const basegfx::BColor& rBColor)
      33             :         {
      34        1250 :             static vcl::DeleteOnDeinit< BitmapEx > aRetVal(0);
      35        1250 :             static basegfx::BColor aColor;
      36        1250 :             static ::osl::Mutex aMutex;
      37             : 
      38        1250 :             ::osl::MutexGuard aGuard(aMutex);
      39             : 
      40        1250 :             if(!aRetVal.get() || rBColor != aColor)
      41             :             {
      42             :                 // copy values
      43          35 :                 aColor = rBColor;
      44             : 
      45             :                 // create bitmap
      46          35 :                 Bitmap aContent(Size(3, 3), 24);
      47          70 :                 Bitmap aMask(Size(3, 3), 1);
      48          35 :                 BitmapWriteAccess* pWContent = aContent.AcquireWriteAccess();
      49          35 :                 BitmapWriteAccess* pWMask = aMask.AcquireWriteAccess();
      50             :                 OSL_ENSURE(pWContent && pWMask, "No WriteAccess to bitmap (!)");
      51          35 :                 const Color aVCLColor(aColor);
      52          70 :                 const BitmapColor aPixColor(aVCLColor);
      53          70 :                 const BitmapColor aMaskColor(0x01);
      54             : 
      55             :                 // Y,X unusual order (!)
      56          35 :                 pWContent->SetPixel(0, 1, aPixColor);
      57          35 :                 pWContent->SetPixel(1, 0, aPixColor);
      58          35 :                 pWContent->SetPixel(1, 1, aPixColor);
      59          35 :                 pWContent->SetPixel(1, 2, aPixColor);
      60          35 :                 pWContent->SetPixel(2, 1, aPixColor);
      61             : 
      62          35 :                 pWMask->SetPixel(0, 0, aMaskColor);
      63          35 :                 pWMask->SetPixel(0, 2, aMaskColor);
      64          35 :                 pWMask->SetPixel(2, 0, aMaskColor);
      65          35 :                 pWMask->SetPixel(2, 2, aMaskColor);
      66             : 
      67          35 :                 aContent.ReleaseAccess(pWContent);
      68          35 :                 aMask.ReleaseAccess(pWMask);
      69             : 
      70             :                 // create and exchange at aRetVal
      71          70 :                 delete aRetVal.set(new BitmapEx(aContent, aMask));
      72             :             }
      73             : 
      74        1250 :             return aRetVal.get() ? *aRetVal.get() : BitmapEx();
      75             :         }
      76             :     } // end of namespace primitive2d
      77         651 : } // end of namespace drawinglayer
      78             : 
      79             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10