Merge branch 'oversample_shift' of https://github.com/rygorous/stb
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Sean Barrett · committed by Sean Barrett · parents d1c85ea, d9e121f · Browse files · 2 files·+22 added−23 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+22 added−23 removed
- other:+22 added−23 removed
Provenance
- Commit
34eec7c- Tree
43a1ed7- Author
Sean Barrett <sean2@nothings.org>- Committer
Sean Barrett <sean2@nothings.org>- Parent 1
d1c85ea- Parent 2
d9e121f
2 files changed+22 added−23 removed
modified:stb_rect_pack.h+4 added-4 removed
234 unmodified lines235 // node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly)236 context->extra[0].x = 0;237 context->extra[0].y = 0;238 context->extra[0].next = &context->extra[1];239- context->extra[1].x = width;239+ context->extra[1].x = (stbrp_coord) width;240 #ifdef STBRP_LARGE_RECTS241 context->extra[1].y = (1<<30);242 #else243 context->extra[1].y = 65535;166 unmodified lines410 }411 412 // on success, create new node413 node = context->free_head;414- node->x = res.x;415- node->y = res.y + height;414+ node->x = (stbrp_coord) res.x;415+ node->y = (stbrp_coord) (res.y + height);416 417 context->free_head = node->next;418 419 // insert the new node into the right starting point, and23 unmodified lines443 // stitch the list back in444 node->next = cur;445 446 if (cur->x < res.x + width)447- cur->x = res.x+width;447+ cur->x = (stbrp_coord) (res.x + width);448 449 #ifdef _DEBUG450 cur = context->active_head;451 while (cur->x < context->width) {95 unmodified linesmodified:stb_truetype.h+18 added-19 removed
879 unmodified lines880 #ifndef STBTT_MAX_OVERSAMPLE881 #define STBTT_MAX_OVERSAMPLE 8882 #endif883 884-typedef stbtt__test_oversample_pow2[(STBTT_MAX_OVERSAMPLE & (STBTT_MAX_OVERSAMPLE-1)) == 0 ? 1 : -1];884+typedef int stbtt__test_oversample_pow2[(STBTT_MAX_OVERSAMPLE & (STBTT_MAX_OVERSAMPLE-1)) == 0 ? 1 : -1];885 886 //////////////////////////////////////////////////////////////////////////887 //888 // accessors to parse data from file1295 unmodified lines2184 int j;2185 for (j=0; j < h; ++j) {2186 int i;2187 unsigned int total;2188- unsigned char *pixels_ahead = pixels + (kernel_width);2188 memset(buffer, 0, kernel_width);2189 2190 total = 0;2191 2 unmodified lines2194 case 2:2195 for (i=0; i <= safe_w; ++i) {2196 total += pixels[i] - buffer[i & STBTT__OVER_MASK];2197 buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i];2199- pixels[i] = total / 2;2198+ pixels[i] = (unsigned char) (total / 2);2199 }2200 break;2201 case 3:2202 for (i=0; i <= safe_w; ++i) {2203 total += pixels[i] - buffer[i & STBTT__OVER_MASK];2204 buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i];2206- pixels[i] = total / 3;2205+ pixels[i] = (unsigned char) (total / 3);2206 }2207 break;2208 case 4:2209 for (i=0; i <= safe_w; ++i) {2210 total += pixels[i] - buffer[i & STBTT__OVER_MASK];2211 buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i];2213- pixels[i] = total / 4;2212+ pixels[i] = (unsigned char) (total / 4);2213 }2214 break;2215 default:2216 for (i=0; i <= safe_w; ++i) {2217 total += pixels[i] - buffer[i & STBTT__OVER_MASK];2218 buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i];2220- pixels[i] = total / kernel_width;2219+ pixels[i] = (unsigned char) (total / kernel_width);2220 }2221 break;2222 }2223 2224 for (; i < w; ++i) {2225 assert(pixels[i] == 0);2226 total -= buffer[i & STBTT__OVER_MASK];2228- pixels[i] = total / kernel_width;2227+ pixels[i] = (unsigned char) (total / kernel_width);2228 }2229 2230 pixels += stride_in_bytes;2231 }6 unmodified lines2238 int j;2239 for (j=0; j < w; ++j) {2240 int i;2241 unsigned int total;2243- unsigned char *pixels_ahead = pixels + (kernel_width)*stride_in_bytes;2242 memset(buffer, 0, kernel_width);2243 2244 total = 0;2245 2 unmodified lines2248 case 2:2249 for (i=0; i <= safe_h; ++i) {2250 total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK];2251 buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes];2254- pixels[i*stride_in_bytes] = total / 2;2252+ pixels[i*stride_in_bytes] = (unsigned char) (total / 2);2253 }2254 break;2255 case 3:2256 for (i=0; i <= safe_h; ++i) {2257 total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK];2258 buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes];2261- pixels[i*stride_in_bytes] = total / 3;2259+ pixels[i*stride_in_bytes] = (unsigned char) (total / 3);2260 }2261 break;2262 case 4:2263 for (i=0; i <= safe_h; ++i) {2264 total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK];2265 buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes];2268- pixels[i*stride_in_bytes] = total / 4;2266+ pixels[i*stride_in_bytes] = (unsigned char) (total / 4);2267 }2268 break;2269 default:2270 for (i=0; i <= safe_h; ++i) {2271 total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK];2272 buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes];2275- pixels[i*stride_in_bytes] = total / kernel_width;2273+ pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width);2274 }2275 break;2276 }2277 2278 for (; i < h; ++i) {2279 assert(pixels[i*stride_in_bytes] == 0);2280 total -= buffer[i & STBTT__OVER_MASK];2283- pixels[i*stride_in_bytes] = total / kernel_width;2281+ pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width);2282 }2283 2284 pixels += 1;2285 }49 unmodified lines2335 scale * spc->h_oversample,2336 scale * spc->v_oversample,2337 0,0,2338 &x0,&y0,&x1,&y1);2341- rects[k].w = x1-x0 + spc->padding + spc->h_oversample-1;2342- rects[k].h = y1-y0 + spc->padding + spc->v_oversample-1;2339+ rects[k].w = (stbrp_coord) (x1-x0 + spc->padding + spc->h_oversample-1);2340+ rects[k].h = (stbrp_coord) (y1-y0 + spc->padding + spc->v_oversample-1);2341 ++k;2342 }2343 }2344 8 unmodified lines2353 if (r->was_packed) {2354 stbtt_packedchar *bc = &ranges[i].chardata_for_range[j];2355 int advance, lsb, x0,y0,x1,y1;2356 int glyph = stbtt_FindGlyphIndex(&info, ranges[i].first_unicode_char_in_range + j);2357+ stbrp_coord pad = (stbrp_coord) spc->padding;2358 2359 // pad on left and top2361- r->x += spc->padding;2362- r->y += spc->padding;2363- r->w -= spc->padding;2364- r->h -= spc->padding;2360+ r->x += pad;2361+ r->y += pad;2362+ r->w -= pad;2363+ r->h -= pad;2364 stbtt_GetGlyphHMetrics(&info, glyph, &advance, &lsb);2365 stbtt_GetGlyphBitmapBox(&info, glyph,2366 scale * spc->h_oversample,2367 scale * spc->v_oversample,241 unmodified lines