/*  $Id: pixel_buffer_memory.cpp,v 1.8 2003/07/20 22:31:49 grumbel 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 "pixel_buffer_memory.h"

/////////////////////////////////////////////////////////////////////////////
// CL_PixelBuffer_Memory construction:

CL_PixelBuffer_Memory::CL_PixelBuffer_Memory(
	int width, int height, int pitch, const CL_PixelFormat &format, void *data_ptr)
{
	CL_PixelBuffer_Generic::width = width;
	CL_PixelBuffer_Generic::height = height;
	CL_PixelBuffer_Generic::pitch = pitch;
	CL_PixelBuffer_Generic::format = format;

	if (data_ptr)
	{
		delete_data = false;
		data = (unsigned char *) data_ptr;
	}
	else
	{
		delete_data = true;
		data = new unsigned char[pitch*height];
	}
}

CL_PixelBuffer_Memory::CL_PixelBuffer_Memory(
	int width, int height, int pitch, const CL_PixelFormat &format, const CL_Palette &palette, void *data_ptr)
{
	CL_PixelBuffer_Generic::width = width;
	CL_PixelBuffer_Generic::height = height;
	CL_PixelBuffer_Generic::pitch = pitch;
	CL_PixelBuffer_Generic::format = format;
	CL_PixelBuffer_Generic::palette = palette;

	if (data_ptr)
	{
		delete_data = false;
		data = (unsigned char *) data_ptr;
	}
	else
	{
		delete_data = true;
		data = new unsigned char[pitch*height];
	}
}

CL_PixelBuffer_Memory::~CL_PixelBuffer_Memory()
{
	if (delete_data) delete[] data;
}

/////////////////////////////////////////////////////////////////////////////
// CL_PixelBuffer_Memory operations:

void *CL_PixelBuffer_Memory::get_data()
{
	return data;
}

void CL_PixelBuffer_Memory::perform_lock()
{
}

void CL_PixelBuffer_Memory::perform_unlock()
{
}

/////////////////////////////////////////////////////////////////////////////
// CL_PixelBuffer_Memory implementation:

