The Battle for Wesnoth  1.15.0+dev
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
surface Class Reference

#include <surface.hpp>

Public Member Functions

 surface ()
 
 surface (SDL_Surface *surf)
 
 surface (int w, int h)
 Allocates a new surface with the given dimensions. More...
 
 surface (const surface &s)
 
 surface (surface &&s) noexcept
 
 ~surface ()
 
surfaceoperator= (const surface &s)
 
surfaceoperator= (SDL_Surface *surf)
 
surfaceoperator= (surface &&s) noexcept
 
void clear_without_free ()
 
bool is_neutral () const
 Check that the surface is neutral bpp 32. More...
 
surfacemake_neutral ()
 Converts this surface to a neutral format if it is not already. More...
 
surface clone () const
 Makes a copy of this surface. More...
 
 operator SDL_Surface * () const
 
SDL_Surface * get () const
 
SDL_Surface * operator-> () const
 

Private Member Functions

void assign_surface_internal (SDL_Surface *surf)
 
void free_surface ()
 

Static Private Member Functions

static void add_surface_ref (SDL_Surface *surf)
 

Private Attributes

SDL_Surface * surface_
 

Static Private Attributes

static const SDL_PixelFormat neutral_pixel_format
 

Detailed Description

Definition at line 23 of file surface.hpp.

Constructor & Destructor Documentation

◆ surface() [1/5]

surface::surface ( )
inline

Definition at line 26 of file surface.hpp.

References h, and w.

Referenced by clone().

◆ surface() [2/5]

surface::surface ( SDL_Surface *  surf)

Definition at line 27 of file surface.cpp.

References make_neutral().

◆ surface() [3/5]

surface::surface ( int  w,
int  h 
)

Allocates a new surface with the given dimensions.

Definition at line 33 of file surface.cpp.

References neutral_pixel_format, and surface_.

◆ surface() [4/5]

surface::surface ( const surface s)
inline

Definition at line 34 of file surface.hpp.

References add_surface_ref(), and surface_.

◆ surface() [5/5]

surface::surface ( surface &&  s)
inlinenoexcept

Definition at line 39 of file surface.hpp.

References s.

◆ ~surface()

surface::~surface ( )
inline

Definition at line 44 of file surface.hpp.

References free_surface().

Member Function Documentation

◆ add_surface_ref()

static void surface::add_surface_ref ( SDL_Surface *  surf)
inlinestaticprivate

Definition at line 104 of file surface.hpp.

References assign_surface_internal(), and free_surface().

Referenced by assign_surface_internal(), and surface().

◆ assign_surface_internal()

void surface::assign_surface_internal ( SDL_Surface *  surf)
private

Definition at line 81 of file surface.cpp.

References add_surface_ref(), free_surface(), make_neutral(), and surface_.

Referenced by add_surface_ref(), and operator=().

◆ clear_without_free()

void surface::clear_without_free ( )
inline

Definition at line 70 of file surface.hpp.

References clone(), is_neutral(), make_neutral(), and surface_.

◆ clone()

surface surface::clone ( ) const

◆ free_surface()

void surface::free_surface ( )
private

Definition at line 89 of file surface.cpp.

References sdl_get_version(), and surface_.

Referenced by add_surface_ref(), assign_surface_internal(), make_neutral(), operator=(), and ~surface().

◆ get()

SDL_Surface* surface::get ( ) const
inline

◆ is_neutral()

bool surface::is_neutral ( ) const

Check that the surface is neutral bpp 32.

The surface may have an empty alpha channel.

Returns
The status true if neutral, false if not.

Definition at line 52 of file surface.cpp.

References SDL_ALPHA_MASK, SDL_RED_MASK, and surface_.

Referenced by gui2::canvas::blit(), blit_surface(), clear_without_free(), and make_neutral().

◆ make_neutral()

surface & surface::make_neutral ( )

Converts this surface to a neutral format if it is not already.

Returns
A reference to this object for chaining convenience.

Definition at line 61 of file surface.cpp.

References free_surface(), is_neutral(), neutral_pixel_format, and surface_.

Referenced by assign_surface_internal(), clear_without_free(), and surface().

◆ operator SDL_Surface *()

surface::operator SDL_Surface * ( ) const
inline

Definition at line 97 of file surface.hpp.

References surface_.

◆ operator->()

SDL_Surface* surface::operator-> ( ) const
inline

Definition at line 101 of file surface.hpp.

References surface_.

◆ operator=() [1/3]

surface& surface::operator= ( const surface s)
inline

Definition at line 49 of file surface.hpp.

References assign_surface_internal(), and get().

◆ operator=() [2/3]

surface& surface::operator= ( SDL_Surface *  surf)
inline

Definition at line 55 of file surface.hpp.

References assign_surface_internal().

◆ operator=() [3/3]

surface& surface::operator= ( surface &&  s)
inlinenoexcept

Definition at line 61 of file surface.hpp.

References free_surface(), s, and surface_.

Member Data Documentation

◆ neutral_pixel_format

const SDL_PixelFormat surface::neutral_pixel_format
staticprivate
Initial value:
= []() {
return *SDL_CreateRGBSurface(0, 1, 1, 32, SDL_RED_MASK, SDL_GREEN_MASK, SDL_BLUE_MASK, SDL_ALPHA_MASK)->format;
}()

Definition at line 117 of file surface.hpp.

Referenced by clone(), make_neutral(), and surface().

◆ surface_

SDL_Surface* surface::surface_
private

The documentation for this class was generated from the following files: