1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svx/sdr/primitive2d/sdrprimitivetools.hxx>
21 #include <vcl/bmpacc.hxx>
22 #include <osl/mutex.hxx>
23 #include <vcl/lazydelete.hxx>
25 //////////////////////////////////////////////////////////////////////////////
28 namespace drawinglayer
32 BitmapEx
createDefaultCross_3x3(const basegfx::BColor
& rBColor
)
34 static vcl::DeleteOnDeinit
< BitmapEx
> aRetVal(0);
35 static basegfx::BColor aColor
;
36 static ::osl::Mutex aMutex
;
38 ::osl::MutexGuard
aGuard(aMutex
);
40 if(!aRetVal
.get() || rBColor
!= aColor
)
46 Bitmap
aContent(Size(3, 3), 24);
47 Bitmap
aMask(Size(3, 3), 1);
48 BitmapWriteAccess
* pWContent
= aContent
.AcquireWriteAccess();
49 BitmapWriteAccess
* pWMask
= aMask
.AcquireWriteAccess();
50 OSL_ENSURE(pWContent
&& pWMask
, "No WriteAccess to bitmap (!)");
51 const Color
aVCLColor(aColor
);
52 const BitmapColor
aPixColor(aVCLColor
);
53 const BitmapColor
aMaskColor(0x01);
55 // Y,X unusual order (!)
56 pWContent
->SetPixel(0, 1, aPixColor
);
57 pWContent
->SetPixel(1, 0, aPixColor
);
58 pWContent
->SetPixel(1, 1, aPixColor
);
59 pWContent
->SetPixel(1, 2, aPixColor
);
60 pWContent
->SetPixel(2, 1, aPixColor
);
62 pWMask
->SetPixel(0, 0, aMaskColor
);
63 pWMask
->SetPixel(0, 2, aMaskColor
);
64 pWMask
->SetPixel(2, 0, aMaskColor
);
65 pWMask
->SetPixel(2, 2, aMaskColor
);
67 aContent
.ReleaseAccess(pWContent
);
68 aMask
.ReleaseAccess(pWMask
);
70 // create and exchange at aRetVal
71 delete aRetVal
.set(new BitmapEx(aContent
, aMask
));
74 return aRetVal
.get() ? *aRetVal
.get() : BitmapEx();
76 } // end of namespace primitive2d
77 } // end of namespace drawinglayer
79 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */