4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2012 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 #include "Screen/VirtualCanvas.hpp"
30 VirtualCanvas::VirtualCanvas(UPixelScalar _width
, UPixelScalar _height
)
35 VirtualCanvas::VirtualCanvas(const Canvas
&canvas
,
36 UPixelScalar _width
, UPixelScalar _height
)
41 #else /* !ENABLE_SDL */
43 VirtualCanvas::VirtualCanvas(UPixelScalar _width
, UPixelScalar _height
)
44 :Canvas(::CreateCompatibleDC(NULL
), _width
, _height
)
48 VirtualCanvas::VirtualCanvas(const Canvas
&canvas
,
49 UPixelScalar _width
, UPixelScalar _height
)
50 :Canvas(::CreateCompatibleDC(canvas
), _width
, _height
)
52 assert(canvas
.IsDefined());
55 #endif /* !ENABLE_SDL */
59 VirtualCanvas::~VirtualCanvas()
67 VirtualCanvas::set(UPixelScalar _width
, UPixelScalar _height
)
69 assert((PixelScalar
)_width
>= 0);
70 assert((PixelScalar
)_height
>= 0);
73 Canvas::set(_width
, _height
);
79 const SDL_Surface
*video
= ::SDL_GetVideoSurface();
80 assert(video
!= NULL
);
81 const SDL_PixelFormat
*format
= video
->format
;
84 surface
= ::SDL_CreateRGBSurface(SDL_SWSURFACE
, _width
, _height
,
86 format
->Rmask
, format
->Gmask
,
87 format
->Bmask
, format
->Amask
);
90 #else /* !ENABLE_SDL */
91 Canvas::set(CreateCompatibleDC(NULL
), _width
, _height
);
92 #endif /* !ENABLE_SDL */
97 VirtualCanvas::set(const Canvas
&canvas
,
98 UPixelScalar _width
, UPixelScalar _height
)
100 assert(canvas
.IsDefined());
103 set(_width
, _height
);
104 #else /* !ENABLE_SDL */
106 Canvas::set(CreateCompatibleDC(canvas
), _width
, _height
);
107 #endif /* !ENABLE_SDL */
111 VirtualCanvas::set(const Canvas
&canvas
)
113 set(canvas
, canvas
.get_width(), canvas
.get_height());
117 void VirtualCanvas::reset()
124 #endif /* !ENABLE_SDL */