Rename utils.allocator to utils.gpa
it seems like `gpa` has become pretty much the universally agreed upon name for your... gpa, so we're renaming.
This commit is contained in:
parent
1df6820b1d
commit
95425aa73f
14 changed files with 89 additions and 90 deletions
|
|
@ -9,17 +9,17 @@ pixels: std.ArrayList(u32),
|
|||
|
||||
// TODO: Make image_path nullable, if null, do a single color with a single_pixel_buffer instead(?)
|
||||
pub fn create(image_path: []const u8) !*WallpaperImage {
|
||||
var wallpaper_image = try utils.allocator.create(WallpaperImage);
|
||||
errdefer utils.allocator.destroy(wallpaper_image);
|
||||
var wallpaper_image = try utils.gpa.create(WallpaperImage);
|
||||
errdefer utils.gpa.destroy(wallpaper_image);
|
||||
|
||||
var read_buf: [zigimg.io.DEFAULT_BUFFER_SIZE]u8 = undefined;
|
||||
var image = try zigimg.Image.fromFilePath(utils.allocator, image_path, &read_buf);
|
||||
defer image.deinit(utils.allocator);
|
||||
var image = try zigimg.Image.fromFilePath(utils.gpa, image_path, &read_buf);
|
||||
defer image.deinit(utils.gpa);
|
||||
|
||||
// We don't want to deal with all the possible formats,
|
||||
// so let's just convert to one we can use with pixman.
|
||||
if (image.pixelFormat() != .rgba32) {
|
||||
try image.convert(utils.allocator, .rgba32);
|
||||
try image.convert(utils.gpa, .rgba32);
|
||||
}
|
||||
|
||||
log.debug("image loaded ({}x{})", .{ image.width, image.height });
|
||||
|
|
@ -27,8 +27,8 @@ pub fn create(image_path: []const u8) !*WallpaperImage {
|
|||
const pixels = image.pixels.rgba32;
|
||||
// We have to manually convert to argb --
|
||||
// It's only guaranteed that Wayland compositors will have xrgb and argb support but zigimg doesn't have either of those.
|
||||
wallpaper_image.pixels = try std.ArrayList(u32).initCapacity(utils.allocator, pixels.len);
|
||||
errdefer wallpaper_image.pixels.deinit(utils.allocator);
|
||||
wallpaper_image.pixels = try std.ArrayList(u32).initCapacity(utils.gpa, pixels.len);
|
||||
errdefer wallpaper_image.pixels.deinit(utils.gpa);
|
||||
for (0..pixels.len) |i| {
|
||||
const a: u32 = @intCast(pixels[i].a);
|
||||
const r: u32 = @intCast(pixels[i].r);
|
||||
|
|
@ -45,9 +45,9 @@ pub fn create(image_path: []const u8) !*WallpaperImage {
|
|||
|
||||
pub fn destroy(wallpaper_image: *WallpaperImage) void {
|
||||
_ = wallpaper_image.image.unref();
|
||||
wallpaper_image.pixels.deinit(utils.allocator);
|
||||
wallpaper_image.pixels.deinit(utils.gpa);
|
||||
|
||||
utils.allocator.destroy(wallpaper_image);
|
||||
utils.gpa.destroy(wallpaper_image);
|
||||
}
|
||||
|
||||
const std = @import("std");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue