コード例 #1
0
ファイル: XMLDom.cpp プロジェクト: morningto/SkyEngine
XMLNodePtr XMLDocument::Parse( ResIdentifierPtr const & source){
	source->seekg( 0, std::ios_base::end );
	int len = static_cast<int>(source->tellg());
	source->seekg( 0, std::ios_base::beg );
	xml_src_.resize( len+1, 0 );
	source->read( &xml_src_[0], len );

	static_cast< rapidxml::xml_document<>* >(doc_)->parse<0>( &xml_src_[0] );
	root_ = MakeSharedPtr<XMLNode>(static_cast<rapidxml::xml_document<>*>(doc_)->first_node());
	return root_;
}
コード例 #2
0
ファイル: LZMACodec.cpp プロジェクト: TomCN7/KlayGE
	void LZMACodec::Decode(std::vector<uint8_t>& output, ResIdentifierPtr const & is, uint64_t len, uint64_t original_len)
	{
		std::vector<uint8_t> in_data(static_cast<size_t>(len));
		is->read(&in_data[0], static_cast<size_t>(len));

		this->Decode(output, &in_data[0], len, original_len);
	}
コード例 #3
0
ファイル: LZMACodec.cpp プロジェクト: TomCN7/KlayGE
	void LZMACodec::Encode(std::vector<uint8_t>& output, ResIdentifierPtr const & is, uint64_t len)
	{
		std::vector<uint8_t> input(static_cast<size_t>(len));
		is->read(&input[0], static_cast<size_t>(len));

		this->Encode(output, &input[0], len);
	}
コード例 #4
0
ファイル: LZMACodec.cpp プロジェクト: TomCN7/KlayGE
	uint64_t LZMACodec::Encode(std::ostream& os, ResIdentifierPtr const & is, uint64_t len)
	{
		std::vector<uint8_t> input(static_cast<size_t>(len));
		is->read(&input[0], static_cast<size_t>(len));

		std::vector<uint8_t> output;
		this->Encode(output, &input[0], len);
		os.write(reinterpret_cast<char*>(&output[0]), output.size() * sizeof(output[0]));

		return output.size();
	}
コード例 #5
0
ファイル: LZMACodec.cpp プロジェクト: TomCN7/KlayGE
	uint64_t LZMACodec::Decode(std::ostream& os, ResIdentifierPtr const & is, uint64_t len, uint64_t original_len)
	{
		std::vector<uint8_t> in_data(static_cast<size_t>(len));
		is->read(&in_data[0], static_cast<size_t>(len));

		std::vector<uint8_t> output;
		this->Decode(output, &in_data[0], len, original_len);

		os.write(reinterpret_cast<char*>(&output[0]), static_cast<std::streamsize>(output.size()));

		return output.size();
	}
コード例 #6
0
ファイル: kfont.cpp プロジェクト: ImNaohaing/KlayGE
	bool KFont::Load(ResIdentifierPtr const & kfont_input)
	{
		if (kfont_input)
		{
			kfont_input_ = kfont_input;

			kfont_header header;
			kfont_input->read(&header, sizeof(header));
			header.fourcc = LE2Native(header.fourcc);
			header.version = LE2Native(header.version);
			header.start_ptr = LE2Native(header.start_ptr);
			header.validate_chars = LE2Native(header.validate_chars);
			header.non_empty_chars = LE2Native(header.non_empty_chars);
			header.char_size = LE2Native(header.char_size);
			header.base = LE2Native(header.base);
			header.scale = LE2Native(header.scale);
			if ((MakeFourCC<'K', 'F', 'N', 'T'>::value == header.fourcc) && (KFONT_VERSION == header.version))
			{
				char_size_ = header.char_size;
				dist_base_ = header.base;
				dist_scale_ = header.scale;

				kfont_input->seekg(header.start_ptr, std::ios_base::beg);

				std::vector<std::pair<int32_t, int32_t>> temp_char_index(header.non_empty_chars);
				kfont_input->read(&temp_char_index[0], temp_char_index.size() * sizeof(temp_char_index[0]));
				std::vector<std::pair<int32_t, uint32_t>> temp_char_advance(header.validate_chars);
				kfont_input->read(&temp_char_advance[0], temp_char_advance.size() * sizeof(temp_char_advance[0]));

				for (auto& ci : temp_char_index)
				{
					ci.first = LE2Native(ci.first);
					ci.second = LE2Native(ci.second);

					KLAYGE_EMPLACE(char_index_advance_, ci.first, std::make_pair(ci.second, 0));
				}
				for (auto& ca : temp_char_advance)
				{
					ca.first = LE2Native(ca.first);
					ca.second = LE2Native(ca.second);

					auto iter = char_index_advance_.find(ca.first);
					if (iter != char_index_advance_.end())
					{
						iter->second.second = ca.second;
					}
					else
					{
						char_index_advance_[ca.first] = std::make_pair(-1, ca.second);
					}
				}

				char_info_.resize(header.non_empty_chars);
				kfont_input->read(&char_info_[0], char_info_.size() * sizeof(char_info_[0]));

				for (auto& ci : char_info_)
				{
					ci.left = LE2Native(ci.left);
					ci.top = LE2Native(ci.top);
					ci.width = LE2Native(ci.width);
					ci.height = LE2Native(ci.height);
				}

				distances_addr_.resize(header.non_empty_chars + 1);
				distances_lzma_start_ = kfont_input->tellg();
				size_t distances_lzma_size = 0;

				for (uint32_t i = 0; i < header.non_empty_chars; ++ i)
				{
					distances_addr_[i] = distances_lzma_size;

					uint64_t len;
					kfont_input->read(&len, sizeof(len));
					len = LE2Native(len);
					distances_lzma_size += static_cast<size_t>(len);

					kfont_input->seekg(len, std::ios_base::cur);
				}

				distances_addr_[header.non_empty_chars] = distances_lzma_size;

				return true;
			}
		}

		return false;
	}
コード例 #7
0
ファイル: FXMLJIT.cpp プロジェクト: BitYorkie/KlayGE
int main(int argc, char* argv[])
{
	using namespace std::experimental;

	if (argc < 2)
	{
		cout << "Usage: FXMLJIT pc_dx11|pc_dx10|pc_dx9|win_tegra3|pc_gl4|pc_gl3|pc_gl2|android_tegra3|ios xxx.fxml [target folder]" << endl;
		return 1;
	}

	ResLoader::Instance().AddPath("../../Tools/media/PlatformDeployer");

	std::string platform = argv[1];

	if (("pc_dx11" == platform) || ("pc_dx10" == platform) || ("pc_dx9" == platform) || ("win_tegra3" == platform)
		|| ("pc_gl4" == platform) || ("pc_gl3" == platform) || ("pc_gl2" == platform)
		|| ("android_tegra3" == platform) || ("ios" == platform))
	{
		if ("pc_dx11" == platform)
		{
			platform = "d3d_11_0";
		}
		else if ("pc_dx10" == platform)
		{
			platform = "d3d_10_0";
		}
		else if ("pc_dx9" == platform)
		{
			platform = "d3d_9_3";
		}
		else if ("win_tegra3" == platform)
		{
			platform = "d3d_9_1";
		}
		else if ("pc_gl4" == platform)
		{
			platform = "gl_4_0";
		}
		else if ("pc_gl3" == platform)
		{
			platform = "gl_3_0";
		}
		else if ("pc_gl2" == platform)
		{
			platform = "gl_2_0";
		}
		else if ("android_tegra3" == platform)
		{
			platform = "gles_2_0";
		}
		else if ("ios" == platform)
		{
			platform = "gles_2_0";
		}
	}

	boost::algorithm::to_lower(platform);

	filesystem::path target_folder;
	if (argc >= 4)
	{
		target_folder = argv[3];
	}

	Offline::OfflineRenderDeviceCaps caps = LoadPlatformConfig(platform);

	std::string fxml_name(argv[2]);
	filesystem::path fxml_path(fxml_name);
#ifdef KLAYGE_TS_LIBRARY_FILESYSTEM_V2_SUPPORT
	std::string const base_name = fxml_path.stem();
#else
	std::string const base_name = fxml_path.stem().string();
#endif
	filesystem::path fxml_directory = fxml_path.parent_path();
	ResLoader::Instance().AddPath(fxml_directory.string());

	filesystem::path kfx_name(base_name + ".kfx");
	filesystem::path kfx_path = fxml_directory / kfx_name;
	bool skip_jit = false;
	if (filesystem::exists(kfx_path))
	{
		ResIdentifierPtr source = ResLoader::Instance().Open(fxml_name);
		ResIdentifierPtr kfx_source = ResLoader::Instance().Open(kfx_path.string());

		uint64_t src_timestamp = source->Timestamp();

		uint32_t fourcc;
		kfx_source->read(&fourcc, sizeof(fourcc));
		fourcc = LE2Native(fourcc);

		uint32_t ver;
		kfx_source->read(&ver, sizeof(ver));
		ver = LE2Native(ver);

		if ((MakeFourCC<'K', 'F', 'X', ' '>::value == fourcc) && (KFX_VERSION == ver))
		{
			uint32_t shader_fourcc;
			kfx_source->read(&shader_fourcc, sizeof(shader_fourcc));
			shader_fourcc = LE2Native(shader_fourcc);

			uint32_t shader_ver;
			kfx_source->read(&shader_ver, sizeof(shader_ver));
			shader_ver = LE2Native(shader_ver);

			if ((caps.native_shader_fourcc == shader_fourcc) && (caps.native_shader_version == shader_ver))
			{
				uint64_t timestamp;
				kfx_source->read(&timestamp, sizeof(timestamp));
				timestamp = LE2Native(timestamp);
				if (src_timestamp <= timestamp)
				{
					skip_jit = true;
				}
			}
		}
	}

	if (!skip_jit)
	{
		Offline::RenderEffect effect(caps);
		effect.Load(fxml_name);
	}
	if (!target_folder.empty())
	{
		filesystem::copy_file(kfx_path, target_folder / kfx_name,
#ifdef KLAYGE_TS_LIBRARY_FILESYSTEM_V3_SUPPORT
			filesystem::copy_options::overwrite_existing);
#else
			filesystem::copy_option::overwrite_if_exists);
#endif
		kfx_path = target_folder / kfx_name;
	}