File tree Expand file tree Collapse file tree 2 files changed +27
-6
lines changed Expand file tree Collapse file tree 2 files changed +27
-6
lines changed Original file line number Diff line number Diff line change 22
22
23
23
#include < utils/compiler.h>
24
24
25
+ class cgltf_texture ;
26
+
25
27
namespace filament {
26
28
class Engine ;
27
29
class Texture ;
@@ -86,7 +88,16 @@ class UTILS_PUBLIC TextureProvider {
86
88
* Texture object, but it is only safe to do so after it has been popped from the queue.
87
89
*/
88
90
virtual Texture* pushTexture (const uint8_t * data, size_t byteCount,
89
- const char * mimeType, FlagBits flags) = 0;
91
+ const char * mimeType, FlagBits flags) {
92
+ return nullptr ;
93
+ }
94
+
95
+ /* *
96
+ * Alternate version of pushTexture, takes raw cgltf_texture data to allow more control.
97
+ */
98
+ virtual Texture* pushTexture (const cgltf_texture* srcTexture, FlagBits flags) {
99
+ return nullptr ;
100
+ }
90
101
91
102
/* *
92
103
* Checks if any texture is ready to be removed from the asynchronous decoding queue, and if so
Original file line number Diff line number Diff line change @@ -616,16 +616,26 @@ void ResourceLoader::asyncUpdateLoad() {
616
616
617
617
Texture* ResourceLoader::Impl::getOrCreateTexture (FFilamentAsset* asset, const TextureSlot& tb) {
618
618
const cgltf_texture* srcTexture = tb.texture ;
619
- const cgltf_image* image = srcTexture->basisu_image ?
620
- srcTexture->basisu_image : srcTexture->image ;
621
- const cgltf_buffer_view* bv = image->buffer_view ;
622
- const char * uri = image->uri ;
623
-
624
619
TextureProvider::FlagBits flags = {};
625
620
if (tb.srgb ) {
626
621
flags |= int (TextureProvider::Flags::sRGB );
627
622
}
628
623
624
+ // Check if there is a texture provider that can work with cgtlf_texture.
625
+ if (auto iter = mTextureProviders .find (" cgltf_texture" ); iter != mTextureProviders .end ()) {
626
+ TextureProvider* provider = iter->second ;
627
+ Texture* texture = provider->pushTexture (srcTexture, flags);
628
+ if (texture) {
629
+ // Note we didn't pass ownership to asset. Caller is responsible for cleaning up.
630
+ return texture;
631
+ }
632
+ }
633
+
634
+ const cgltf_image* image = srcTexture->basisu_image ?
635
+ srcTexture->basisu_image : srcTexture->image ;
636
+ const cgltf_buffer_view* bv = image->buffer_view ;
637
+ const char * uri = image->uri ;
638
+
629
639
std::string mime = image->mime_type ? image->mime_type : " " ;
630
640
size_t dataUriSize;
631
641
const uint8_t * dataUriContent = uri ? parseDataUri (uri, &mime, &dataUriSize) : nullptr ;
You can’t perform that action at this time.
0 commit comments