mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-02 09:02:03 +02:00
47 lines
933 B
C++
47 lines
933 B
C++
|
/*
|
||
|
* CCanvas.cpp, part of VCMI engine
|
||
|
*
|
||
|
* Authors: listed in file AUTHORS in main folder
|
||
|
*
|
||
|
* License: GNU General Public License v2.0 or later
|
||
|
* Full text of license available in license.txt file, in main folder
|
||
|
*
|
||
|
*/
|
||
|
#include "StdInc.h"
|
||
|
#include "CCanvas.h"
|
||
|
|
||
|
#include "SDL_Extensions.h"
|
||
|
#include "Geometries.h"
|
||
|
#include "CAnimation.h"
|
||
|
|
||
|
CCanvas::CCanvas(SDL_Surface * surface):
|
||
|
surface(surface)
|
||
|
{
|
||
|
surface->refcount++;
|
||
|
}
|
||
|
|
||
|
CCanvas::CCanvas(const Point & size)
|
||
|
{
|
||
|
surface = CSDL_Ext::newSurface(size.x, size.y);
|
||
|
}
|
||
|
|
||
|
CCanvas::~CCanvas()
|
||
|
{
|
||
|
SDL_FreeSurface(surface);
|
||
|
}
|
||
|
|
||
|
void CCanvas::draw(std::shared_ptr<IImage> image, const Point & pos)
|
||
|
{
|
||
|
image->draw(surface, pos.x, pos.y);
|
||
|
}
|
||
|
|
||
|
void CCanvas::draw(std::shared_ptr<CCanvas> image, const Point & pos)
|
||
|
{
|
||
|
image->copyTo(surface, pos);
|
||
|
}
|
||
|
|
||
|
void CCanvas::copyTo(SDL_Surface * to, const Point & pos)
|
||
|
{
|
||
|
blitAt(to, pos.x, pos.y, surface);
|
||
|
}
|