4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 #include "MapDrawHelper.hpp"
27 #include "Screen/Canvas.hpp"
28 #include "Projection/WindowProjection.hpp"
29 #include "Renderer/AirspaceRendererSettings.hpp"
30 #include "MapCanvas.hpp"
31 #include "Geo/SearchPointVector.hpp"
33 MapDrawHelper::MapDrawHelper(Canvas
&_canvas
, Canvas
&_buffer
, Canvas
&_stencil
,
34 const WindowProjection
&_proj
,
35 const AirspaceRendererSettings
&_settings
)
36 :clip(_proj
.GetScreenBounds().Scale(fixed(1.1))),
47 MapDrawHelper::MapDrawHelper(const MapDrawHelper
&other
)
51 stencil(other
.stencil
),
53 buffer_drawn(other
.buffer_drawn
),
54 use_stencil(other
.use_stencil
),
55 settings(other
.settings
)
60 MapDrawHelper::DrawSearchPointVector(const SearchPointVector
&points
)
62 size_t size
= points
.size();
66 /* copy all SearchPointVector elements to geo_points */
67 geo_points
.GrowDiscard(size
* 3);
68 for (unsigned i
= 0; i
< size
; ++i
)
69 geo_points
[i
] = points
[i
].GetLocation();
72 size
= clip
.ClipPolygon(geo_points
.begin(), geo_points
.begin(), size
);
74 /* it's completely outside the screen */
78 RasterPoint screen
[size
];
79 for (unsigned i
= 0; i
< size
; ++i
)
80 screen
[i
] = proj
.GeoToScreen(geo_points
[i
]);
82 if (!MapCanvas::IsVisible(canvas
, screen
, size
))
85 buffer
.DrawPolygon(&screen
[0], size
);
87 stencil
.DrawPolygon(&screen
[0], size
);
91 MapDrawHelper::DrawCircle(const RasterPoint
¢er
, unsigned radius
)
93 buffer
.DrawCircle(center
.x
, center
.y
, radius
);
95 stencil
.DrawCircle(center
.x
, center
.y
, radius
);
99 MapDrawHelper::BufferRenderFinish()
104 buffer
.CopyTransparentBlack(stencil
);
106 buffer
.CopyOr(stencil
);
110 #ifdef HAVE_ALPHA_BLEND
111 if (settings
.transparency
&& AlphaBlendAvailable())
112 canvas
.AlphaBlend(0, 0, canvas
.GetWidth(), canvas
.GetHeight(),
114 0, 0, canvas
.GetWidth(), canvas
.GetHeight(),
118 canvas
.CopyAnd(buffer
);
120 buffer_drawn
= false;
125 MapDrawHelper::BufferRenderStart()
134 MapDrawHelper::ClearBuffer()
139 stencil
.ClearWhite();
142 #endif // !ENABLE_OPENGL