Skip to content

Commit

Permalink
Add a separate cache for brightened images.
Browse files Browse the repository at this point in the history
  • Loading branch information
lipk committed Jun 17, 2014
1 parent 6181499 commit 561cb5b
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/image.cpp
Expand Up @@ -128,7 +128,8 @@ image::image_cache images_,
#if SDL_VERSION_ATLEAST(2,0,0)
/** Rexture caches */
image::texture_cache txt_images_,
txt_hexed_images_;
txt_hexed_images_,
txt_brightened_images_;
#endif

// cache storing if each image fit in a hex
Expand Down Expand Up @@ -910,16 +911,31 @@ sdl::ttexture get_texture(const locator& loc, TYPE type)

texture_cache *cache;

if (type == UNSCALED || type == SCALED_TO_ZOOM) {
cache = &txt_images_;
} else {
switch (type) {
case UNSCALED:
case SCALED_TO_ZOOM:
cache = &txt_hexed_images_;
break;
case BRIGHTENED:
cache = &txt_brightened_images_;
break;
case HEXED:
case SCALED_TO_HEX:
case TOD_COLORED:
cache = &txt_hexed_images_;
break;
default:
return sdl::ttexture();
}

if (!loc.in_cache(*cache)) {
if (type == UNSCALED || type == SCALED_TO_ZOOM) {
sdl::ttexture txt = load_texture(loc);
loc.add_to_cache(*cache, txt);
} else if (type == BRIGHTENED) {
surface surf = get_brightened(loc);
sdl::ttexture txt = CVideo::get_window()->create_texture(SDL_TEXTUREACCESS_STATIC, surf);
loc.add_to_cache(*cache, txt);
} else {
surface surf = get_hexed(loc);
sdl::ttexture txt = CVideo::get_window()->create_texture(SDL_TEXTUREACCESS_STATIC, surf);
Expand All @@ -932,9 +948,8 @@ sdl::ttexture get_texture(const locator& loc, TYPE type)
switch (type) {
case UNSCALED:
case HEXED:
break;
case BRIGHTENED:
//TODO: brighten
break;
case TOD_COLORED:
result.set_color_mod(red_adjust, green_adjust, blue_adjust);
case SCALED_TO_ZOOM:
Expand Down

0 comments on commit 561cb5b

Please sign in to comment.