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 0 : Color OutputDevice::GetPixel( const Point& rPt ) const
36 : {
37 :
38 0 : Color aColor;
39 :
40 0 : if ( mpGraphics || AcquireGraphics() )
41 : {
42 0 : if ( mbInitClipRegion )
43 0 : const_cast<OutputDevice*>(this)->InitClipRegion();
44 :
45 0 : if ( !mbOutputClipped )
46 : {
47 0 : const long nX = ImplLogicXToDevicePixel( rPt.X() );
48 0 : const long nY = ImplLogicYToDevicePixel( rPt.Y() );
49 0 : const SalColor aSalCol = mpGraphics->GetPixel( nX, nY, this );
50 0 : aColor.SetRed( SALCOLOR_RED( aSalCol ) );
51 0 : aColor.SetGreen( SALCOLOR_GREEN( aSalCol ) );
52 0 : aColor.SetBlue( SALCOLOR_BLUE( aSalCol ) );
53 : }
54 : }
55 0 : return aColor;
56 : }
57 :
58 116493 : void OutputDevice::DrawPixel( const Point& rPt )
59 : {
60 :
61 116493 : if ( mpMetaFile )
62 1956 : mpMetaFile->AddAction( new MetaPointAction( rPt ) );
63 :
64 116493 : if ( !IsDeviceOutputNecessary() || !mbLineColor || ImplIsRecordLayout() )
65 2019 : return;
66 :
67 116493 : Point aPt = ImplLogicToDevicePixel( rPt );
68 :
69 116493 : if ( !mpGraphics && !AcquireGraphics() )
70 0 : return;
71 :
72 116493 : if ( mbInitClipRegion )
73 9497 : InitClipRegion();
74 :
75 116493 : if ( mbOutputClipped )
76 2019 : return;
77 :
78 114474 : if ( mbInitLineColor )
79 104683 : InitLineColor();
80 :
81 114474 : mpGraphics->DrawPixel( aPt.X(), aPt.Y(), this );
82 :
83 114474 : if( mpAlphaVDev )
84 1896 : mpAlphaVDev->DrawPixel( rPt );
85 : }
86 :
87 1166846 : void OutputDevice::DrawPixel( const Point& rPt, const Color& rColor )
88 : {
89 :
90 1166846 : Color aColor = ImplDrawModeToColor( rColor );
91 :
92 1166846 : if ( mpMetaFile )
93 0 : mpMetaFile->AddAction( new MetaPixelAction( rPt, aColor ) );
94 :
95 1166846 : if ( !IsDeviceOutputNecessary() || ImplIsColorTransparent( aColor ) || ImplIsRecordLayout() )
96 0 : return;
97 :
98 1166846 : Point aPt = ImplLogicToDevicePixel( rPt );
99 :
100 1166846 : if ( !mpGraphics && !AcquireGraphics() )
101 0 : return;
102 :
103 1166846 : if ( mbInitClipRegion )
104 18649 : InitClipRegion();
105 :
106 1166846 : if ( mbOutputClipped )
107 0 : return;
108 :
109 1166846 : mpGraphics->DrawPixel( aPt.X(), aPt.Y(), ImplColorToSal( aColor ), this );
110 :
111 1166846 : if( mpAlphaVDev )
112 0 : mpAlphaVDev->DrawPixel( rPt );
113 : }
114 :
115 0 : void OutputDevice::DrawPixel( const Polygon& rPts, const Color* pColors )
116 : {
117 0 : if ( !pColors )
118 : {
119 0 : DrawPixel( rPts, GetLineColor() );
120 : }
121 : else
122 : {
123 : DBG_ASSERT( pColors, "OutputDevice::DrawPixel: No color array specified" );
124 :
125 0 : const sal_uInt16 nSize = rPts.GetSize();
126 :
127 0 : if ( nSize )
128 : {
129 0 : if ( mpMetaFile )
130 : {
131 0 : for ( sal_uInt16 i = 0; i < nSize; i++ )
132 : {
133 0 : mpMetaFile->AddAction( new MetaPixelAction( rPts[ i ], pColors[ i ] ) );
134 : }
135 : }
136 0 : if ( !IsDeviceOutputNecessary() || ImplIsRecordLayout() )
137 0 : return;
138 :
139 0 : if ( mpGraphics || AcquireGraphics() )
140 : {
141 0 : if ( mbInitClipRegion )
142 0 : InitClipRegion();
143 :
144 0 : if ( mbOutputClipped )
145 0 : return;
146 :
147 0 : for ( sal_uInt16 i = 0; i < nSize; i++ )
148 : {
149 0 : const Point aPt( ImplLogicToDevicePixel( rPts[ i ] ) );
150 0 : mpGraphics->DrawPixel( aPt.X(), aPt.Y(), ImplColorToSal( pColors[ i ] ), this );
151 : }
152 : }
153 : }
154 : }
155 :
156 0 : if( mpAlphaVDev )
157 0 : mpAlphaVDev->DrawPixel( rPts, pColors );
158 : }
159 :
160 0 : void OutputDevice::DrawPixel( const Polygon& rPts, const Color& rColor )
161 : {
162 0 : if( rColor != COL_TRANSPARENT && ! ImplIsRecordLayout() )
163 : {
164 0 : const sal_uInt16 nSize = rPts.GetSize();
165 0 : boost::scoped_array<Color> pColArray(new Color[ nSize ]);
166 :
167 0 : for( sal_uInt16 i = 0; i < nSize; i++ )
168 : {
169 0 : pColArray[ i ] = rColor;
170 : }
171 0 : DrawPixel( rPts, pColArray.get() );
172 : }
173 :
174 0 : if( mpAlphaVDev )
175 0 : mpAlphaVDev->DrawPixel( rPts, rColor );
176 1233 : }
177 :
178 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|