22 #ifndef FIFE_VIDEO_ATLASBOOK_H
23 #define FIFE_VIDEO_ATLASBOOK_H
36 #include "util/structures/rect.h"
43 uint32_t left, right, top, bottom;
45 AtlasBlock(
const Rect& rect, uint32_t page)
47 left(rect.x), right(rect.right()),
48 top(rect.y), bottom(rect.bottom()){
69 left = right = top = bottom = 0;
72 bool isTrivial()
const {
73 return getWidth() == 0 || getHeight() == 0;
76 uint32_t getWidth()
const {
return right - left; }
77 uint32_t getHeight()
const {
return bottom - top; }
79 AtlasBlock intersects(AtlasBlock
const& rect)
const;
80 void merge(AtlasBlock
const& rect);
85 AtlasPage(uint32_t width, uint32_t height,
86 uint32_t pixelSize, uint32_t page)
87 : width(width), height(height), pixelSize(pixelSize),
88 page(page), freePixels(width*height*pixelSize){
91 AtlasBlock* getBlock(uint32_t width, uint32_t height);
92 void shrink(
bool pot);
94 uint32_t getWidth()
const {
98 uint32_t getHeight()
const {
103 AtlasBlock
const* intersects(AtlasBlock
const* block)
const;
105 uint32_t width, height;
110 typedef std::vector<AtlasBlock> Blocks;
117 AtlasBook(uint32_t pageWidth, uint32_t pageHeight,
118 uint32_t pixelSize = 4)
119 : pageWidth(pageWidth), pageHeight(pageHeight),
120 pixelSize(pixelSize) {
123 AtlasBlock* getBlock(uint32_t width, uint32_t height);
126 void shrink(
bool pot);
128 AtlasPage& getPage(
size_t index) {
134 AtlasPage* extendCache(uint32_t minPageWidth, uint32_t minPageHeight);
137 uint32_t pageWidth, pageHeight;
140 typedef std::vector<AtlasPage> Pages;