2006-02-05 18:56:30 +00:00
|
|
|
/**
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2006-02-05 18:56:30 +00:00
|
|
|
*
|
|
|
|
* This program 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; either version 2
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2006-02-05 18:56:30 +00:00
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2006-02-05 18:56:30 +00:00
|
|
|
*
|
|
|
|
* Contributor(s): Peter Schlaile <peter@schlaile.de> 2005
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2006-02-05 18:56:30 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __MEM_Allocator_h_included__
|
|
|
|
#define __MEM_Allocator_h_included__ 1
|
|
|
|
|
|
|
|
#include "guardedalloc/MEM_guardedalloc.h"
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
#include "guardedalloc/BLO_sys_types.h"
|
2006-02-05 18:56:30 +00:00
|
|
|
|
2006-02-09 22:09:11 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#if _MSC_VER < 1300 // 1200 == VC++ 6.0 according to boost
|
|
|
|
#define MS_VISUALC_6_0_WORKAROUND 1
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2006-02-05 18:56:30 +00:00
|
|
|
template<typename _Tp>
|
|
|
|
struct MEM_Allocator
|
|
|
|
{
|
|
|
|
typedef size_t size_type;
|
|
|
|
typedef ptrdiff_t difference_type;
|
|
|
|
typedef _Tp* pointer;
|
|
|
|
typedef const _Tp* const_pointer;
|
|
|
|
typedef _Tp& reference;
|
|
|
|
typedef const _Tp& const_reference;
|
|
|
|
typedef _Tp value_type;
|
|
|
|
|
2006-02-09 22:09:11 +00:00
|
|
|
#ifndef MS_VISUALC_6_0_WORKAROUND
|
2006-02-05 18:56:30 +00:00
|
|
|
template<typename _Tp1>
|
|
|
|
struct rebind {
|
|
|
|
typedef MEM_Allocator<_Tp1> other;
|
|
|
|
};
|
2006-02-09 22:09:11 +00:00
|
|
|
#endif
|
2006-02-05 18:56:30 +00:00
|
|
|
|
|
|
|
MEM_Allocator() throw() {}
|
2006-03-04 16:23:15 +00:00
|
|
|
MEM_Allocator(const MEM_Allocator&) throw() {}
|
2006-02-05 18:56:30 +00:00
|
|
|
|
2006-02-09 22:09:11 +00:00
|
|
|
#ifndef MS_VISUALC_6_0_WORKAROUND
|
2006-02-05 18:56:30 +00:00
|
|
|
template<typename _Tp1>
|
2006-03-04 16:23:15 +00:00
|
|
|
MEM_Allocator(const MEM_Allocator<_Tp1>) throw() { }
|
2006-02-09 22:09:11 +00:00
|
|
|
#endif
|
2006-02-05 18:56:30 +00:00
|
|
|
|
|
|
|
~MEM_Allocator() throw() {}
|
|
|
|
|
|
|
|
pointer address(reference __x) const { return &__x; }
|
|
|
|
|
|
|
|
const_pointer address(const_reference __x) const { return &__x; }
|
|
|
|
|
2006-02-09 22:09:11 +00:00
|
|
|
#ifdef MS_VISUALC_6_0_WORKAROUND
|
|
|
|
char *_Charalloc(size_type n) {
|
|
|
|
return (char *) MEM_mallocN(n, "STL MEM_Allocator VC6.0");
|
|
|
|
}
|
|
|
|
#endif
|
2006-02-05 18:56:30 +00:00
|
|
|
// NB: __n is permitted to be 0. The C++ standard says nothing
|
|
|
|
// about what the return value is when __n == 0.
|
|
|
|
_Tp* allocate(size_type __n, const void* = 0) {
|
|
|
|
_Tp* __ret = 0;
|
|
|
|
if (__n)
|
|
|
|
__ret = static_cast<_Tp*>(
|
|
|
|
MEM_mallocN(__n * sizeof(_Tp),
|
|
|
|
"STL MEM_Allocator"));
|
|
|
|
return __ret;
|
|
|
|
}
|
|
|
|
|
2006-02-09 22:09:11 +00:00
|
|
|
#ifndef MS_VISUALC_6_0_WORKAROUND
|
2006-02-05 18:56:30 +00:00
|
|
|
// __p is not permitted to be a null pointer.
|
|
|
|
void deallocate(pointer __p, size_type){
|
|
|
|
MEM_freeN(__p);
|
|
|
|
}
|
2006-02-09 22:09:11 +00:00
|
|
|
#else
|
|
|
|
// __p is not permitted to be a null pointer.
|
|
|
|
void deallocate(void* __p, size_type){
|
|
|
|
MEM_freeN(__p);
|
|
|
|
}
|
|
|
|
#endif
|
2006-02-05 18:56:30 +00:00
|
|
|
|
|
|
|
size_type max_size() const throw() {
|
|
|
|
return size_t(-1) / sizeof(_Tp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void construct(pointer __p, const _Tp& __val) {
|
|
|
|
new(__p) _Tp(__val);
|
|
|
|
}
|
|
|
|
|
|
|
|
void destroy(pointer __p) {
|
|
|
|
__p->~_Tp();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|