dlgTextEntry_Keyboard: rename to TouchTextEntry
[xcsoar.git] / src / MapWindow / MapDrawHelper.cpp
blob8aeaa64999ff8c441239e3ffd2ea350fc2a876ba
1 /*
2 Copyright_License {
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.
24 #ifndef ENABLE_OPENGL
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))),
37 canvas(_canvas),
38 buffer(_buffer),
39 stencil(_stencil),
40 proj(_proj),
41 buffer_drawn(false),
42 use_stencil(false),
43 settings(_settings)
47 MapDrawHelper::MapDrawHelper(const MapDrawHelper &other)
48 :clip(other.clip),
49 canvas(other.canvas),
50 buffer(other.buffer),
51 stencil(other.stencil),
52 proj(other.proj),
53 buffer_drawn(other.buffer_drawn),
54 use_stencil(other.use_stencil),
55 settings(other.settings)
59 void
60 MapDrawHelper::DrawSearchPointVector(const SearchPointVector &points)
62 size_t size = points.size();
63 if (size < 3)
64 return;
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();
71 /* clip them */
72 size = clip.ClipPolygon(geo_points.begin(), geo_points.begin(), size);
73 if (size < 3)
74 /* it's completely outside the screen */
75 return;
77 /* draw it all */
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))
83 return;
85 buffer.DrawPolygon(&screen[0], size);
86 if (use_stencil)
87 stencil.DrawPolygon(&screen[0], size);
90 void
91 MapDrawHelper::DrawCircle(const RasterPoint &center, unsigned radius)
93 buffer.DrawCircle(center.x, center.y, radius);
94 if (use_stencil)
95 stencil.DrawCircle(center.x, center.y, radius);
98 void
99 MapDrawHelper::BufferRenderFinish()
101 if (buffer_drawn) {
102 if (use_stencil) {
103 #ifdef ENABLE_SDL
104 buffer.CopyTransparentBlack(stencil);
105 #else
106 buffer.CopyOr(stencil);
107 #endif
110 #ifdef HAVE_ALPHA_BLEND
111 if (settings.transparency && AlphaBlendAvailable())
112 canvas.AlphaBlend(0, 0, canvas.GetWidth(), canvas.GetHeight(),
113 buffer,
114 0, 0, canvas.GetWidth(), canvas.GetHeight(),
115 60);
116 else
117 #endif
118 canvas.CopyAnd(buffer);
120 buffer_drawn = false;
124 void
125 MapDrawHelper::BufferRenderStart()
127 if (!buffer_drawn) {
128 ClearBuffer();
129 buffer_drawn = true;
133 void
134 MapDrawHelper::ClearBuffer()
136 buffer.ClearWhite();
138 if (use_stencil)
139 stencil.ClearWhite();
142 #endif // !ENABLE_OPENGL