2020-06-21 02:27:08 +08:00
|
|
|
|
#ifndef HGL_GRAPH_TILE_DATA_INCLUDE
|
2019-11-06 20:52:09 +08:00
|
|
|
|
#define HGL_GRAPH_TILE_DATA_INCLUDE
|
|
|
|
|
|
2020-07-24 17:50:46 +08:00
|
|
|
|
#include<hgl/type/Pool.h>
|
2023-07-28 20:17:46 +08:00
|
|
|
|
#include<hgl/graph/BitmapData.h>
|
|
|
|
|
#include<hgl/graph/ImageRegion.h>
|
|
|
|
|
#include<hgl/graph/tile/TileObject.h>
|
2020-10-21 11:43:18 +08:00
|
|
|
|
#include<hgl/graph/VKTexture.h>
|
2020-06-20 19:40:09 +08:00
|
|
|
|
|
|
|
|
|
VK_NAMESPACE_USING
|
2019-11-06 20:52:09 +08:00
|
|
|
|
namespace hgl
|
|
|
|
|
{
|
|
|
|
|
namespace graph
|
|
|
|
|
{
|
|
|
|
|
/**
|
2020-06-20 19:40:09 +08:00
|
|
|
|
* TileData是一种处理大量等同尺寸及格式贴图的管理机制,程序会自动根据显卡最大贴图处理能力来创建尽可能符合需求的贴图。(注:Tile的大小不必符合2次幂)
|
|
|
|
|
* Tile的增加或删除,程序会自动排序,尽可能小的减少I/O消耗。
|
|
|
|
|
*/
|
2020-06-21 18:29:48 +08:00
|
|
|
|
class TileData ///Tile纹理管理
|
2019-11-06 20:52:09 +08:00
|
|
|
|
{
|
2020-10-21 12:39:22 +08:00
|
|
|
|
GPUDevice *device;
|
2020-06-21 17:50:25 +08:00
|
|
|
|
|
2019-11-06 20:52:09 +08:00
|
|
|
|
protected:
|
|
|
|
|
|
2020-06-21 18:29:48 +08:00
|
|
|
|
Texture2D *tile_texture; ///<TileData所用的纹理对象
|
2019-11-06 20:52:09 +08:00
|
|
|
|
|
2020-07-24 20:25:30 +08:00
|
|
|
|
ObjectPool<TileObject> to_pool; ///<Tile对象池
|
2019-11-06 20:52:09 +08:00
|
|
|
|
|
2020-06-21 18:29:48 +08:00
|
|
|
|
uint tile_width,tile_height; ///<Tile的宽和高
|
2020-07-29 17:06:43 +08:00
|
|
|
|
uint tile_bytes; ///<一个tile字节数
|
2020-07-29 15:24:41 +08:00
|
|
|
|
uint tile_count,tile_max_count; ///<当前Tile数量与最大数量
|
|
|
|
|
uint tile_rows,tile_cols; ///<贴图中可用的Tile行数和列数
|
2019-11-06 20:52:09 +08:00
|
|
|
|
|
|
|
|
|
protected:
|
2020-07-31 18:01:28 +08:00
|
|
|
|
|
2022-10-14 17:52:35 +08:00
|
|
|
|
DeviceBuffer *tile_buffer; ///<Tile暂存缓冲区
|
2020-07-29 17:06:43 +08:00
|
|
|
|
|
2021-12-15 19:57:35 +08:00
|
|
|
|
List<Image2DRegion> commit_list;
|
2020-07-29 17:06:43 +08:00
|
|
|
|
uint8 *commit_ptr;
|
|
|
|
|
|
|
|
|
|
bool CommitTile(TileObject *,const void *,const uint,const int,const int); ///<提交一个Tile数据
|
2020-07-31 18:01:28 +08:00
|
|
|
|
|
2020-07-29 15:24:41 +08:00
|
|
|
|
public:
|
2019-11-06 20:52:09 +08:00
|
|
|
|
|
2020-07-29 15:24:41 +08:00
|
|
|
|
int GetWidth ()const{return tile_width;} ///<取得Tile宽
|
|
|
|
|
int GetHeight ()const{return tile_height;} ///<取得Tile高
|
|
|
|
|
int GetCount ()const{return tile_count;} ///<取得Tile数量
|
|
|
|
|
int GetMaxCount ()const{return tile_max_count;} ///<取得Tile最大数量
|
|
|
|
|
int GetFreeCount()const{return tile_max_count-tile_count;} ///<取得空余Tile数量
|
2019-11-06 20:52:09 +08:00
|
|
|
|
|
2020-07-29 15:24:41 +08:00
|
|
|
|
Texture2D * GetTexture ()const{return tile_texture;} ///<取得贴图
|
2019-11-06 20:52:09 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2020-10-21 12:39:22 +08:00
|
|
|
|
TileData(GPUDevice *,Texture2D *,const uint tw,const uint th);
|
2020-07-29 15:24:41 +08:00
|
|
|
|
virtual ~TileData();
|
2019-11-06 20:52:09 +08:00
|
|
|
|
|
2020-07-29 17:06:43 +08:00
|
|
|
|
void BeginCommit();
|
|
|
|
|
|
|
|
|
|
TileObject *Commit(const void *,const uint,const int=-1,const int=-1); ///<提交一个Tile
|
|
|
|
|
TileObject *Commit(BitmapData *bmp){return this->Commit(bmp->data,bmp->total_bytes,bmp->width,bmp->height);}///<提交一个Tile
|
2020-07-31 22:21:44 +08:00
|
|
|
|
|
|
|
|
|
TileObject *Acquire(); ///<请求一个Tile
|
2020-07-29 17:06:43 +08:00
|
|
|
|
bool Change(TileObject *,const void *,const uint,const int=-1,const int=-1); ///<更改一个Tile的数据内容
|
|
|
|
|
|
|
|
|
|
int EndCommit();
|
2019-11-06 20:52:09 +08:00
|
|
|
|
|
2020-07-29 15:24:41 +08:00
|
|
|
|
bool Delete(TileObject *); ///<删除一个Tile
|
|
|
|
|
void Clear(); ///<清除Tile数据
|
2019-11-06 20:52:09 +08:00
|
|
|
|
};//class TileData
|
|
|
|
|
}//namespace graph
|
|
|
|
|
}//namespace hgl
|
|
|
|
|
#endif//HGL_GRAPH_TILE_DATA_INCLUDE
|