Debian Codegraph @

src/effect/SurfaceLock.cpp

raw
1 /*
2 * Copyright (C) 2004 Ivo Danihelka ([email protected])
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 */
9 #include "SurfaceLock.h"
10
11 #include "SDLException.h"
12
13
14 //-----------------------------------------------------------------
15 /**
16 * Lock surface when necessary.
17 * @throws SDLException when surface cannot be locked
18 */
19 SurfaceLock::SurfaceLock(SDL_Surface *surface)
20 {
21 m_surface = surface;
22 if (SDL_MUSTLOCK(m_surface)) {
23 if (SDL_LockSurface(m_surface) < 0) {
24 throw SDLException(ExInfo("LockSurface"));
25 }
26 }
27 }
28 //-----------------------------------------------------------------
29 /**
30 * Unlock surface.
31 */
32 SurfaceLock::~SurfaceLock()
33 {
34 if (SDL_MUSTLOCK(m_surface)) {
35 SDL_UnlockSurface(m_surface);
36 }
37 }