android - Best way to find and remove hidden textures from memory -
i need find way track positions loaded textures drawn. when of loaded textures overwritten, have delete them memory.
i have remote user interface (rui) server sends me lot of small images, assembled , shown on rui client's screen. in scenario, have no clue textures behind other textures, unable delete them. also, overwriting must complete (texture behind must totally hidden). there efficient way achieve tracking , deleting?
my use-case this: have menu button images stored on server. whole screen made of fragments (buttons, scrollbars, animations etc.). example, when click on button, server sends me multiple thumbnails of pictures stored in storage, , display them in ,for example, right half of screen. on other button click, list of songs, videos, ebooks or else shown. need remove textures of picture thumbnails memory , show list of songs, example. in way, overwriting disappear, , memory usage reduced.
my opengl es 2.0 implementation on android platform, whole job done in jni layer. there no complicated drawing, decoding png images, converting textures, , basic textures displaying.
you can along lines of reference counting keep track of how many times same image has been used. when instance entirely occluded or off-screen, decrement reference count, , delete textures 0 references.
reference counting simple std::map<texture, int>
.
your occlusion check o(n^2) aabb intersection/containment test , o(n) test against screen's aabb. if that's not fast enough you, try better data structure quadtree or spatial hashing.
depending on how application set up, track instances of texture type of smart pointer , figure out when of hidden views have been deleted.
that being said, waste of time unless you're bound amount of vram on device or getting close it. loading/unloading images either disk or network location going orders of magnitude slower keeping in vram if have available.
Comments
Post a Comment