Skip to content

Commit 2f46a08

Browse files
soreautrigg
authored andcommitted
window-list: Use get_rowstride() from Gdk::Pixbuf for stride
1 parent b456eda commit 2f46a08

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

src/panel/widgets/window-list/toplevel.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,6 @@ static void dmabuf_created(void *data, struct zwp_linux_buffer_params_v1*,
6868
{
6969
TooltipMedia *tooltip_media = (TooltipMedia*)data;
7070

71-
if (tooltip_media->buffer)
72-
{
73-
wl_buffer_destroy(tooltip_media->buffer);
74-
}
75-
7671
tooltip_media->buffer = wl_buffer;
7772
}
7873

@@ -136,35 +131,39 @@ static void frame_handle_ready(void *data,
136131
tooltip_media->height,
137132
stride);
138133

139-
auto w = 500;
140-
auto h = tooltip_media->height * (500.0f / tooltip_media->width);
134+
gbm_bo_unmap(tooltip_media->bo, map_data);
135+
136+
uint32_t w = 500;
137+
uint32_t h = tooltip_media->height * (500.0f / tooltip_media->width);
141138

142139
auto scaled_pixbuf = pixbuf->scale_simple(
143140
w, h, Gdk::InterpType::BILINEAR);
144141

142+
w = scaled_pixbuf->get_width();
143+
h = scaled_pixbuf->get_height();
144+
uint32_t s = scaled_pixbuf->get_rowstride();
145+
145146
/* Swap red and blue channels */
146-
size_t size = w * h * 4;
147+
size_t size = s * h;
147148
pixel_data = scaled_pixbuf->get_pixels();
148149
std::shared_ptr<Glib::Bytes> bytes = Glib::Bytes::create((unsigned char*)pixel_data, size);
149150

150151
if (!bytes)
151152
{
152-
gbm_bo_unmap(tooltip_media->bo, map_data);
153153
return;
154154
}
155155

156156
auto builder = Gdk::MemoryTextureBuilder::create();
157157
builder->set_bytes(bytes);
158158
builder->set_width(w);
159159
builder->set_height(h);
160-
builder->set_stride(w * 4);
160+
builder->set_stride(s);
161161
builder->set_format(Gdk::MemoryFormat::B8G8R8A8);
162162

163163
auto texture = builder->build();
164164

165165
tooltip_media->set_paintable(texture);
166-
167-
gbm_bo_unmap(tooltip_media->bo, map_data);
166+
tooltip_media->frame_in_flight = false;
168167
}
169168

170169
static void frame_handle_failed(void *data,
@@ -320,7 +319,7 @@ TooltipMedia::TooltipMedia(WayfireWindowList *window_list, ext_foreign_toplevel_
320319
this->request_next_frame();
321320

322321
return true;
323-
}, 33);
322+
}, 20);
324323
}
325324

326325
TooltipMedia::~TooltipMedia()

0 commit comments

Comments
 (0)