本文整理汇总了C++中Page::Enlarge方法的典型用法代码示例。如果您正苦于以下问题:C++ Page::Enlarge方法的具体用法?C++ Page::Enlarge怎么用?C++ Page::Enlarge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Page
的用法示例。
在下文中一共展示了Page::Enlarge方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Pack
void PackToBin::Pack(const std::string& filepath,
const ee::TexturePacker& tp,
bool compress,
float scale)
{
std::set<int> ref_pkgs;
uint32_t default_sym_id = 0xffffffff;
const std::string default_sym_path = ee::ImageDataMgr::Instance()->GetDefaultSym();
if (!default_sym_path.empty()) {
int pkg_id, node_id;
PackIDMgr::Instance()->QueryID(default_sym_path, pkg_id, node_id, true);
default_sym_id = simp::NodeID::ComposeID(pkg_id, node_id);
}
// src nodes
std::vector<PackNode*> nodes;
PackNodeFactory::Instance()->FetchAll(nodes);
std::vector<PackNode*>::iterator itr = nodes.begin();
for ( ; itr != nodes.end(); )
{
PackNode* node = *itr;
if (!PackIDMgr::Instance()->IsCurrPkg(node)) {
ref_pkgs.insert(node->GetPkgID());
itr = nodes.erase(itr);
} else {
if (default_sym_id != 0xffffffff && default_sym_id == node->GetID() &&
default_sym_path != node->GetFilepath()) {
itr = nodes.erase(itr);
} else {
++itr;
}
}
}
if (nodes.empty()) {
return;
}
std::sort(nodes.begin(), nodes.end(), PackNodeCmp());
// to pages
std::vector<Page*> pages;
Page* page = new Page(simp::SIMP_PAGE_SIZE);
int page_sz = ALIGN_4BYTE(simp::Page::Size());
for (int i = 0, n = nodes.size(); i < n; ++i)
{
PackNode* node = nodes[i];
int sz = node->SizeOfUnpackFromBin();
while (true)
{
// head sz
int num;
auto& page_nodes = page->GetNodes();
if (page_nodes.empty()) {
num = 1;
} else {
num = node->GetID() - page_nodes[0]->GetID() + 1;
}
int align_n = ALIGN_4BYTE(num);
int head_sz =
sizeof(uint8_t) * align_n + // types
simp::SIZEOF_POINTER * num; // nodes
if (page_sz + head_sz + sz <= page->GetSize()) {
page_sz += sz;
page->Add(node);
break;
}
if (page->NodeNum() > 0) {
page->Condense(page_sz + head_sz);
pages.push_back(page);
page = new Page(simp::SIMP_PAGE_SIZE);
page_sz = ALIGN_4BYTE(simp::Page::Size());
} else {
page->Enlarge();
}
}
}
if (page->NodeNum() > 0)
{
// head sz
auto& page_nodes = page->GetNodes();
int num = page_nodes.back()->GetID() - page_nodes.front()->GetID() + 1;
int align_n = ALIGN_4BYTE(num);
int head_sz =
sizeof(uint8_t) * align_n + // types
simp::SIZEOF_POINTER * num; // nodes
page->Condense(page_sz + head_sz);
pages.push_back(page);
}
// pack index
PageIndex(filepath + ".epe", pages, compress, scale, ref_pkgs);
// pack pages
for (int i = 0, n = pages.size(); i < n; ++i) {
std::string path = filepath + "." + ee::StringHelper::ToString(i + 1) + ".epe";
PackPage(path, *pages[i], tp, compress);
}
}