Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Free standalone textures. #254

Merged
merged 1 commit into from Mar 30, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Free standalone textures.

Addresses servo/servo#9931.
  • Loading branch information
pcwalton committed Mar 30, 2016
commit 7e9a3097325066a8a34c91b227abd268a61ebd59
@@ -579,16 +579,16 @@ impl TextureCacheArena {
}
}

fn texture_page_for_id(&mut self, id: TextureId) -> &mut TexturePage {
fn texture_page_for_id(&mut self, id: TextureId) -> Option<&mut TexturePage> {
for page in self.pages_a8.iter_mut().chain(self.pages_rgb8.iter_mut())
.chain(self.pages_rgba8.iter_mut())
.chain(self.alternate_pages_a8.iter_mut())
.chain(self.alternate_pages_rgba8.iter_mut()) {
if page.texture_id == id {
return page
return Some(page)
}
}
panic!("No texture page for ID {:?}", id)
None
}
}

@@ -1186,8 +1186,16 @@ impl TextureCache {
pub fn free(&mut self, id: TextureCacheItemId) {
{
let item = self.items.get(id);
self.arena.texture_page_for_id(item.texture_id).free(&item.allocated_rect);
match self.arena.texture_page_for_id(item.texture_id) {
Some(texture_page) => texture_page.free(&item.allocated_rect),
None => {
// This is a standalone texture allocation. Just push it back onto the free
// list.
self.free_texture_ids.push(item.texture_id);
}
}
}

self.items.free(id)
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.