/*  $Id: canvas.cpp,v 1.13 2004/05/07 15:15:24 mbn Exp $
**
**  ClanLib Game SDK
**  Copyright (C) 2003  The ClanLib Team
**  For a total list of contributers see the file CREDITS.
**
**  This library is free software; you can redistribute it and/or
**  modify it under the terms of the GNU Lesser General Public
**  License as published by the Free Software Foundation; either
**  version 2.1 of the License, or (at your option) any later version.
**
**  This library 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.  See the GNU
**  Lesser General Public License for more details.
**
**  You should have received a copy of the GNU Lesser General Public
**  License along with this library; if not, write to the Free Software
**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
**
*/

#include "Display/display_precomp.h"
#include "API/Display/canvas.h"
#include "canvas_generic.h"
#include "display_target.h"
#include "API/Display/pixel_buffer.h"

/////////////////////////////////////////////////////////////////////////////
// CL_Canvas construction:

CL_Canvas::CL_Canvas() : impl(CL_DisplayTarget::current->create_canvas())
{
}

CL_Canvas::CL_Canvas(const CL_Surface &initial_active_surface) : impl(CL_DisplayTarget::current->create_canvas())
{
	impl->select_surface(initial_active_surface.impl);
}

CL_Canvas::CL_Canvas(const CL_Canvas &copy) : impl(copy.impl)
{
}

CL_Canvas::~CL_Canvas()
{
}

/////////////////////////////////////////////////////////////////////////////
// CL_Canvas attributes:

CL_GraphicContext *CL_Canvas::get_gc()
{
	return impl->get_gc();
}

CL_PixelBuffer CL_Canvas::get_pixeldata()
{
	return impl->get_pixeldata(CL_Rect(0, 0, get_width(), get_height()));
}

CL_PixelBuffer CL_Canvas::get_pixeldata(const CL_Rect &area)
{
	return impl->get_pixeldata(area);
}

int CL_Canvas::get_width() const
{
	return impl->get_width();
}

int CL_Canvas::get_height() const
{
	return impl->get_height();
}

/////////////////////////////////////////////////////////////////////////////
// CL_Canvas operations:

CL_Canvas &CL_Canvas::operator =(const CL_Canvas &copy)
{
	impl = copy.impl;
	return *this;
}

void CL_Canvas::set_pixeldata(const CL_PixelBuffer &data)
{
	impl->set_pixeldata(CL_Point(0,0), CL_Rect(0, 0, data.get_width(), data.get_height()), data);
}

void CL_Canvas::set_pixeldata(const CL_Point &dest, const CL_PixelBuffer &data)
{
	impl->set_pixeldata(dest, CL_Rect(0, 0, data.get_width(), data.get_height()), data);
}

void CL_Canvas::set_pixeldata(const CL_Point &dest, const CL_Rect &src, const CL_PixelBuffer &data)
{
	impl->set_pixeldata(dest, src, data);
}

void CL_Canvas::select_surface(CL_Surface &surface)
{
	impl->select_surface(surface.impl);
}

void CL_Canvas::sync_surface()
{
	impl->sync_surface();
}

/////////////////////////////////////////////////////////////////////////////
// CL_Canvas implementation:
