Changeset 43842cb in libguac
- Timestamp:
- 04/02/12 00:57:19 (14 months ago)
- Branches:
- master, debian, rpm, unstable
- Children:
- eaf5489
- Parents:
- 502f990
- git-author:
- Michael Jumper <zhangmaike@…> (04/02/12 00:57:19)
- git-committer:
- Michael Jumper <zhangmaike@…> (04/02/12 00:57:19)
- Files:
-
- 2 edited
-
include/palette.h (modified) (1 diff)
-
src/palette.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
include/palette.h
r502f990 r43842cb 57 57 58 58 guac_palette* guac_palette_alloc(cairo_surface_t* surface); 59 int guac_palette_find(guac_palette* palette, int color); 59 60 void guac_palette_free(guac_palette* palette); 60 61 -
src/palette.c
r502f990 r43842cb 112 112 } 113 113 114 int guac_palette_find(guac_palette* palette, int color) { 115 116 /* Calculate hash code */ 117 int hash = ((color & 0xFFF000) >> 12) ^ (color & 0xFFF); 118 119 guac_palette_entry* entry; 120 121 /* Search for palette entry */ 122 for (;;) { 123 124 entry = &(palette->entries[hash]); 125 126 /* If we've found a free space, color not stored. */ 127 if (entry->index == 0) 128 return -1; 129 130 /* Otherwise, if color indeed stored here, done */ 131 if (entry->color == color) 132 return entry->index; 133 134 /* Otherwise, collision. Move on to another bucket */ 135 hash = (hash+1) & 0xFFF; 136 137 } 138 139 } 140 114 141 void guac_palette_free(guac_palette* palette) { 115 142 free(palette);
Note: See TracChangeset
for help on using the changeset viewer.
