Commit 12316f7da11ff3c746ddbd96f4797e20325bb6a9

Authored by Adeel Kazmi
Committed by Gerrit Code Review
2 parents 1bfc5479 9208546a

Merge "Use dali-adaptor api to read files from inside apk" into devel/master

examples/rendering-basic-pbr/ktx-loader.cpp
@@ -93,26 +93,22 @@ bool ConvertPixelFormat(const uint32_t ktxPixelFormat, Dali::Pixel::Format& form @@ -93,26 +93,22 @@ bool ConvertPixelFormat(const uint32_t ktxPixelFormat, Dali::Pixel::Format& form
93 93
94 bool LoadCubeMapFromKtxFile(const std::string& path, CubeData& cubedata) 94 bool LoadCubeMapFromKtxFile(const std::string& path, CubeData& cubedata)
95 { 95 {
96 - std::unique_ptr<FILE, void (*)(FILE*)> fp(fopen(path.c_str(), "rb"), [](FILE* fp) {  
97 - if(fp)  
98 - {  
99 - fclose(fp);  
100 - }  
101 - }); 96 + Dali::FileStream daliFileStream(path);
  97 + FILE* fp(daliFileStream.GetFile());
102 if(!fp) 98 if(!fp)
103 { 99 {
104 return false; 100 return false;
105 } 101 }
106 102
107 KtxFileHeader header; 103 KtxFileHeader header;
108 - int result = fread(&header, sizeof(KtxFileHeader), 1u, fp.get()); 104 + int result = fread(&header, sizeof(KtxFileHeader), 1u, fp);
109 if(0 == result) 105 if(0 == result)
110 { 106 {
111 return false; 107 return false;
112 } 108 }
113 109
114 // Skip the key-values: 110 // Skip the key-values:
115 - if(fseek(fp.get(), header.bytesOfKeyValueData, SEEK_CUR)) 111 + if(fseek(fp, header.bytesOfKeyValueData, SEEK_CUR))
116 { 112 {
117 return false; 113 return false;
118 } 114 }
@@ -151,7 +147,7 @@ bool LoadCubeMapFromKtxFile(const std::string&amp; path, CubeData&amp; cubedata) @@ -151,7 +147,7 @@ bool LoadCubeMapFromKtxFile(const std::string&amp; path, CubeData&amp; cubedata)
151 for(unsigned int mipmapLevel = 0; mipmapLevel < header.numberOfMipmapLevels; ++mipmapLevel) 147 for(unsigned int mipmapLevel = 0; mipmapLevel < header.numberOfMipmapLevels; ++mipmapLevel)
152 { 148 {
153 uint32_t byteSize = 0; 149 uint32_t byteSize = 0;
154 - if(fread(&byteSize, sizeof(byteSize), 1u, fp.get()) != 1) 150 + if(fread(&byteSize, sizeof(byteSize), 1u, fp) != 1)
155 { 151 {
156 return false; 152 return false;
157 } 153 }
@@ -166,7 +162,7 @@ bool LoadCubeMapFromKtxFile(const std::string&amp; path, CubeData&amp; cubedata) @@ -166,7 +162,7 @@ bool LoadCubeMapFromKtxFile(const std::string&amp; path, CubeData&amp; cubedata)
166 for(unsigned int face = 0; face < header.numberOfFaces; ++face) 162 for(unsigned int face = 0; face < header.numberOfFaces; ++face)
167 { 163 {
168 std::unique_ptr<uint8_t, void (*)(void*)> img(static_cast<unsigned char*>(malloc(byteSize)), free); // resources will be freed when the PixelData is destroyed. 164 std::unique_ptr<uint8_t, void (*)(void*)> img(static_cast<unsigned char*>(malloc(byteSize)), free); // resources will be freed when the PixelData is destroyed.
169 - if(fread(img.get(), byteSize, 1u, fp.get()) != 1) 165 + if(fread(img.get(), byteSize, 1u, fp) != 1)
170 { 166 {
171 return false; 167 return false;
172 } 168 }