+ if (scrn->output_texture) {
+ if (!buffer || buffer->width < scrn->width ||
+ buffer->height < scrn->height)
+ allocate_new_buffer = true;
+ else if (scrn->is_different_gpu)
+ /* In case of different gpu we can reuse the linear
+ * texture so we only need to set the external
+ * texture for copying
+ */
+ buffer->texture = scrn->output_texture;
+ else {
+ /* In case of a single gpu we search if the texture is
+ * already present as buffer if not we get the
+ * handle and pixmap for the texture that is set
+ */
+ for (b = 0; b < BACK_BUFFER_NUM; b++) {
+ id = (b + scrn->cur_back) % BACK_BUFFER_NUM;
+ buffer = scrn->back_buffers[id];
+ if (buffer && !buffer->busy &&
+ buffer->texture == scrn->output_texture) {
+ scrn->cur_back = id;
+ break;
+ }
+ }
+
+ if (b == BACK_BUFFER_NUM) {
+ allocate_new_buffer = true;
+ scrn->cur_back = scrn->next_back;
+ scrn->next_back = (scrn->next_back + 1) % BACK_BUFFER_NUM;
+ buffer = scrn->back_buffers[scrn->cur_back];
+ }
+ }
+
+ } else {
+ if (!buffer || buffer->width != scrn->width ||
+ buffer->height != scrn->height)
+ allocate_new_buffer = true;
+ }
+
+ if (allocate_new_buffer) {