{
struct stw_pixelformat_info *pfi;
- assert(stw_dev->pixelformat_extended_count < STW_MAX_PIXELFORMATS);
- if (stw_dev->pixelformat_extended_count >= STW_MAX_PIXELFORMATS)
- return;
-
assert(util_format_get_component_bits(color->format, UTIL_FORMAT_COLORSPACE_RGB, 0) == color->bits.red);
assert(util_format_get_component_bits(color->format, UTIL_FORMAT_COLORSPACE_RGB, 1) == color->bits.green);
assert(util_format_get_component_bits(color->format, UTIL_FORMAT_COLORSPACE_RGB, 2) == color->bits.blue);
assert(util_format_get_component_bits(depth->format, UTIL_FORMAT_COLORSPACE_ZS, 0) == depth->bits.depth);
assert(util_format_get_component_bits(depth->format, UTIL_FORMAT_COLORSPACE_ZS, 1) == depth->bits.stencil);
- pfi = &stw_dev->pixelformats[stw_dev->pixelformat_extended_count];
+ pfi = util_dynarray_grow(&stw_dev->pixelformats,
+ struct stw_pixelformat_info,
+ 1);
memset(pfi, 0, sizeof *pfi);
pfi->bindToTextureRGB = TRUE;
- ++stw_dev->pixelformat_extended_count;
-
if (!extended) {
++stw_dev->pixelformat_count;
- assert(stw_dev->pixelformat_count == stw_dev->pixelformat_extended_count);
+ assert(stw_dev->pixelformat_count ==
+ util_dynarray_num_elements(&stw_dev->pixelformats,
+ struct stw_pixelformat_info));
}
}
unsigned num_formats;
assert(!stw_dev->pixelformat_count);
- assert(!stw_dev->pixelformat_extended_count);
+
+ util_dynarray_init(&stw_dev->pixelformats, NULL);
/* normal, displayable formats */
num_formats = add_color_format_variants(stw_pf_color,
add_color_format_variants(stw_pf_color_extended,
ARRAY_SIZE(stw_pf_color_extended), TRUE);
- assert(stw_dev->pixelformat_count <= stw_dev->pixelformat_extended_count);
- assert(stw_dev->pixelformat_extended_count <= STW_MAX_PIXELFORMATS);
+ assert(stw_dev->pixelformat_count <=
+ util_dynarray_num_elements(&stw_dev->pixelformats,
+ struct stw_pixelformat_info));
}
if (!stw_init_screen(hdc))
return 0;
- return stw_dev->pixelformat_extended_count;
+ return util_dynarray_num_elements(&stw_dev->pixelformats,
+ struct stw_pixelformat_info);
}
}
index = iPixelFormat - 1;
- if (index >= stw_dev->pixelformat_extended_count) {
+ if (index >= util_dynarray_num_elements(&stw_dev->pixelformats,
+ struct stw_pixelformat_info)) {
return NULL;
}
- return &stw_dev->pixelformats[index];
+ return util_dynarray_element(&stw_dev->pixelformats,
+ struct stw_pixelformat_info,
+ index);
}