OpenTTD Source: src/blitter/null.cpp Source File

OpenTTD Source 15.3

null.cpp
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#include "../stdafx.h"
11#include "null.hpp"
12
13#include "../safeguards.h"
14
16 static FBlitter_Null iFBlitter_Null;
17
18 Sprite *Blitter_Null::Encode(SpriteType, const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator)
19{
20 Sprite *dest_sprite;
21 dest_sprite = allocator.Allocate<Sprite>(sizeof(*dest_sprite));
22
23 const auto &root_sprite = sprite.Root();
24 dest_sprite->height = root_sprite.height;
25 dest_sprite->width = root_sprite.width;
26 dest_sprite->x_offs = root_sprite.x_offs;
27 dest_sprite->y_offs = root_sprite.y_offs;
28
29 return dest_sprite;
30}
Blitter_Null::Encode
Sprite * Encode(SpriteType sprite_type, const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator) override
Convert a sprite from the loader to our own format.
Definition null.cpp:18
FBlitter_Null
Factory for the blitter that does nothing.
Definition null.hpp:38
SpriteAllocator
Interface for something that can allocate memory for a sprite.
Definition spriteloader.hpp:104
SpriteAllocator::Allocate
T * Allocate(size_t size)
Allocate memory for a sprite.
Definition spriteloader.hpp:115
SpriteCollMap
Map zoom level to data.
Definition spriteloader.hpp:34
SpriteType
SpriteType
Types of sprites that might be loaded.
Definition gfx_type.h:357
iFBlitter_Null
static FBlitter_Null iFBlitter_Null
Instantiation of the null blitter factory.
Definition null.cpp:16
null.hpp
The blitter that doesn't blit.
Sprite
Data structure describing a sprite.
Definition spritecache_type.h:16
Sprite::width
uint16_t width
Width of the sprite.
Definition spritecache_type.h:18
Sprite::height
uint16_t height
Height of the sprite.
Definition spritecache_type.h:17
Sprite::y_offs
int16_t y_offs
Number of pixels to shift the sprite downwards.
Definition spritecache_type.h:20
Sprite::x_offs
int16_t x_offs
Number of pixels to shift the sprite to the right.
Definition spritecache_type.h:19