Merge branch 'Font-Update'

Former-commit-id: d293f78c891a74554c6b990afafdc1eb1cc0a584
This commit is contained in:
Lynix
2015-01-17 00:36:28 +01:00
108 changed files with 4982 additions and 1081 deletions

View File

@@ -19,6 +19,7 @@ class NzCallOnExit : NzNonCopyable
NzCallOnExit(Func func = nullptr);
~NzCallOnExit();
void CallAndReset(Func func = nullptr);
void Reset(Func func = nullptr);
private:

View File

@@ -2,6 +2,7 @@
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Core/Error.hpp>
#include <Nazara/Core/Debug.hpp>
inline NzCallOnExit::NzCallOnExit(Func func) :
@@ -15,6 +16,14 @@ inline NzCallOnExit::~NzCallOnExit()
m_func();
}
inline void NzCallOnExit::CallAndReset(Func func)
{
if (m_func)
m_func();
Reset(func);
}
inline void NzCallOnExit::Reset(Func func)
{
m_func = func;

View File

@@ -0,0 +1,85 @@
// Copyright (C) 2014 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
// Implémentation originale de Jukka Jylänki (Merci de sa contribution au domaine public)
// http://clb.demon.fi/projects/even-more-rectangle-bin-packing
#pragma once
#ifndef NAZARA_GUILLOTINEBINPACK_HPP
#define NAZARA_GUILLOTINEBINPACK_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/SparsePtr.hpp>
#include <Nazara/Math/Rect.hpp>
#include <vector>
class NAZARA_API NzGuillotineBinPack
{
public:
enum FreeRectChoiceHeuristic
{
RectBestAreaFit,
RectBestLongSideFit,
RectBestShortSideFit,
RectWorstAreaFit,
RectWorstLongSideFit,
RectWorstShortSideFit
};
enum GuillotineSplitHeuristic
{
SplitLongerAxis,
SplitLongerLeftoverAxis,
SplitMaximizeArea,
SplitMinimizeArea,
SplitShorterAxis,
SplitShorterLeftoverAxis
};
NzGuillotineBinPack();
NzGuillotineBinPack(unsigned int width, unsigned int height);
NzGuillotineBinPack(const NzVector2ui& size);
NzGuillotineBinPack(const NzGuillotineBinPack&) = default;
NzGuillotineBinPack(NzGuillotineBinPack&&) = default;
~NzGuillotineBinPack() = default;
void Clear();
void Expand(unsigned int newWidth, unsigned newHeight);
void Expand(const NzVector2ui& newSize);
void FreeRectangle(const NzRectui& rect);
unsigned int GetHeight() const;
float GetOccupancy() const;
NzVector2ui GetSize() const;
unsigned int GetWidth() const;
bool Insert(NzRectui* rects, unsigned int count, bool merge, FreeRectChoiceHeuristic rectChoice, GuillotineSplitHeuristic splitMethod);
bool Insert(NzRectui* rects, bool* flipped, unsigned int count, bool merge, FreeRectChoiceHeuristic rectChoice, GuillotineSplitHeuristic splitMethod);
bool Insert(NzRectui* rects, bool* flipped, bool* inserted, unsigned int count, bool merge, FreeRectChoiceHeuristic rectChoice, GuillotineSplitHeuristic splitMethod);
bool MergeFreeRectangles();
void Reset();
void Reset(unsigned int width, unsigned int height);
void Reset(const NzVector2ui& size);
NzGuillotineBinPack& operator=(const NzGuillotineBinPack&) = default;
NzGuillotineBinPack& operator=(NzGuillotineBinPack&&) = default;
private:
void SplitFreeRectAlongAxis(const NzRectui& freeRect, const NzRectui& placedRect, bool splitHorizontal);
void SplitFreeRectByHeuristic(const NzRectui& freeRect, const NzRectui& placedRect, GuillotineSplitHeuristic method);
static int ScoreByHeuristic(int width, int height, const NzRectui& freeRect, FreeRectChoiceHeuristic rectChoice);
std::vector<NzRectui> m_freeRectangles;
unsigned int m_height;
unsigned int m_usedArea;
unsigned int m_width;
};
#endif // NAZARA_GUILLOTINEBINPACK_HPP

View File

@@ -23,6 +23,8 @@ class NAZARA_API NzResource
{
public:
NzResource(bool persistent = true);
NzResource(const NzResource& resource) = delete;
NzResource(NzResource&& resource) = delete;
virtual ~NzResource();
void AddResourceListener(NzResourceListener* listener, int index = 0) const;
@@ -37,6 +39,9 @@ class NAZARA_API NzResource
bool SetPersistent(bool persistent = true, bool checkReferenceCount = false);
NzResource& operator=(const NzResource& resource) = delete;
NzResource& operator=(NzResource&& resource) = delete;
protected:
void NotifyCreated();
void NotifyDestroy();

View File

@@ -46,7 +46,9 @@ class NzSparsePtr
T& operator[](int index) const;
NzSparsePtr operator+(int count) const;
NzSparsePtr operator+(unsigned int count) const;
NzSparsePtr operator-(int count) const;
NzSparsePtr operator-(unsigned int count) const;
std::ptrdiff_t operator-(const NzSparsePtr& ptr) const;
NzSparsePtr& operator+=(int count);

View File

@@ -127,12 +127,24 @@ NzSparsePtr<T> NzSparsePtr<T>::operator+(int count) const
return NzSparsePtr(m_ptr + count*m_stride, m_stride);
}
template<typename T>
NzSparsePtr<T> NzSparsePtr<T>::operator+(unsigned int count) const
{
return NzSparsePtr(m_ptr + count*m_stride, m_stride);
}
template<typename T>
NzSparsePtr<T> NzSparsePtr<T>::operator-(int count) const
{
return NzSparsePtr(m_ptr - count*m_stride, m_stride);
}
template<typename T>
NzSparsePtr<T> NzSparsePtr<T>::operator-(unsigned int count) const
{
return NzSparsePtr(m_ptr - count*m_stride, m_stride);
}
template<typename T>
std::ptrdiff_t NzSparsePtr<T>::operator-(const NzSparsePtr& ptr) const
{