d2d1: Replace d2d_calloc() with a global heap_calloc() helper.
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Michael Stefaniuc <mstefani@winehq.org> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
bfc0f3bdf1
commit
fa4d5b6151
|
@ -511,7 +511,7 @@ HRESULT d2d_bitmap_create_from_wic_bitmap(ID2D1Factory *factory, ID3D10Device *d
|
||||||
pitch = ((bpp * size.width) + 15) & ~15;
|
pitch = ((bpp * size.width) + 15) & ~15;
|
||||||
if (pitch / bpp < size.width)
|
if (pitch / bpp < size.width)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
if (!(data = d2d_calloc(size.height, pitch)))
|
if (!(data = heap_calloc(size.height, pitch)))
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
data_size = size.height * pitch;
|
data_size = size.height * pitch;
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D10Device *device, const D
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
if (!(data = d2d_calloc(stop_count, 2 * sizeof(*data))))
|
if (!(data = heap_calloc(stop_count, 2 * sizeof(*data))))
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate data.\n");
|
ERR("Failed to allocate data.\n");
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
@ -205,7 +205,7 @@ HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D10Device *device, const D
|
||||||
(*gradient)->view = view;
|
(*gradient)->view = view;
|
||||||
|
|
||||||
(*gradient)->stop_count = stop_count;
|
(*gradient)->stop_count = stop_count;
|
||||||
if (!((*gradient)->stops = d2d_calloc(stop_count, sizeof(*stops))))
|
if (!((*gradient)->stops = heap_calloc(stop_count, sizeof(*stops))))
|
||||||
{
|
{
|
||||||
ID3D10ShaderResourceView_Release(view);
|
ID3D10ShaderResourceView_Release(view);
|
||||||
heap_free(*gradient);
|
heap_free(*gradient);
|
||||||
|
|
|
@ -477,15 +477,6 @@ void d2d_transformed_geometry_init(struct d2d_geometry *geometry, ID2D1Factory *
|
||||||
ID2D1Geometry *src_geometry, const D2D_MATRIX_3X2_F *transform) DECLSPEC_HIDDEN;
|
ID2D1Geometry *src_geometry, const D2D_MATRIX_3X2_F *transform) DECLSPEC_HIDDEN;
|
||||||
struct d2d_geometry *unsafe_impl_from_ID2D1Geometry(ID2D1Geometry *iface) DECLSPEC_HIDDEN;
|
struct d2d_geometry *unsafe_impl_from_ID2D1Geometry(ID2D1Geometry *iface) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
static inline void *d2d_calloc(size_t count, size_t size)
|
|
||||||
{
|
|
||||||
SIZE_T s = count * size;
|
|
||||||
|
|
||||||
if (size && s / size != count)
|
|
||||||
return NULL;
|
|
||||||
return heap_alloc(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline BOOL d2d_array_reserve(void **elements, size_t *capacity, size_t count, size_t size)
|
static inline BOOL d2d_array_reserve(void **elements, size_t *capacity, size_t count, size_t size)
|
||||||
{
|
{
|
||||||
size_t new_capacity, max_capacity;
|
size_t new_capacity, max_capacity;
|
||||||
|
|
|
@ -2025,7 +2025,7 @@ static HRESULT d2d_path_geometry_triangulate(struct d2d_geometry *geometry)
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(vertices = d2d_calloc(vertex_count, sizeof(*vertices))))
|
if (!(vertices = heap_calloc(vertex_count, sizeof(*vertices))))
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
for (i = 0, j = 0; i < geometry->u.path.figure_count; ++i)
|
for (i = 0, j = 0; i < geometry->u.path.figure_count; ++i)
|
||||||
|
@ -2792,7 +2792,7 @@ static HRESULT d2d_geometry_resolve_beziers(struct d2d_geometry *geometry)
|
||||||
geometry->fill.bezier_vertex_count += 3 * geometry->u.path.figures[i].bezier_control_count;
|
geometry->fill.bezier_vertex_count += 3 * geometry->u.path.figures[i].bezier_control_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(geometry->fill.bezier_vertices = d2d_calloc(geometry->fill.bezier_vertex_count,
|
if (!(geometry->fill.bezier_vertices = heap_calloc(geometry->fill.bezier_vertex_count,
|
||||||
sizeof(*geometry->fill.bezier_vertices))))
|
sizeof(*geometry->fill.bezier_vertices))))
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate bezier vertices array.\n");
|
ERR("Failed to allocate bezier vertices array.\n");
|
||||||
|
|
|
@ -1162,7 +1162,7 @@ static void d2d_rt_draw_glyph_run_bitmap(struct d2d_d3d_render_target *render_ta
|
||||||
|
|
||||||
if (texture_type == DWRITE_TEXTURE_CLEARTYPE_3x1)
|
if (texture_type == DWRITE_TEXTURE_CLEARTYPE_3x1)
|
||||||
bitmap_size.width *= 3;
|
bitmap_size.width *= 3;
|
||||||
if (!(opacity_values = d2d_calloc(bitmap_size.height, bitmap_size.width)))
|
if (!(opacity_values = heap_calloc(bitmap_size.height, bitmap_size.width)))
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate opacity values.\n");
|
ERR("Failed to allocate opacity values.\n");
|
||||||
goto done;
|
goto done;
|
||||||
|
|
|
@ -212,7 +212,7 @@ HRESULT d2d_stroke_style_init(struct d2d_stroke_style *style, ID2D1Factory *fact
|
||||||
if (!dashes || !dash_count)
|
if (!dashes || !dash_count)
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
if (!(style->dashes = d2d_calloc(dash_count, sizeof(*style->dashes))))
|
if (!(style->dashes = heap_calloc(dash_count, sizeof(*style->dashes))))
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
memcpy(style->dashes, dashes, dash_count * sizeof(*style->dashes));
|
memcpy(style->dashes, dashes, dash_count * sizeof(*style->dashes));
|
||||||
style->dash_count = dash_count;
|
style->dash_count = dash_count;
|
||||||
|
|
|
@ -46,4 +46,13 @@ static inline void heap_free(void *mem)
|
||||||
HeapFree(GetProcessHeap(), 0, mem);
|
HeapFree(GetProcessHeap(), 0, mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void *heap_calloc(SIZE_T count, SIZE_T size)
|
||||||
|
{
|
||||||
|
SIZE_T len = count * size;
|
||||||
|
|
||||||
|
if (size && len / size != count)
|
||||||
|
return NULL;
|
||||||
|
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* __WINE_WINE_HEAP_H */
|
#endif /* __WINE_WINE_HEAP_H */
|
||||||
|
|
Loading…
Reference in New Issue