Revision ffe8b821

b/console.c
1278 1278
{
1279 1279
    DisplaySurface *surface = (DisplaySurface*) qemu_mallocz(sizeof(DisplaySurface));
1280 1280

  
1281
    surface->width = width;
1282
    surface->height = height;
1283
    surface->linesize = width * 4;
1284
    surface->pf = qemu_default_pixelformat(32);
1285
#ifdef HOST_WORDS_BIGENDIAN
1286
    surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;
1287
#else
1288
    surface->flags = QEMU_ALLOCATED_FLAG;
1289
#endif
1290
    surface->data = (uint8_t*) qemu_mallocz(surface->linesize * surface->height);
1291

  
1281
    int linesize = width * 4;
1282
    qemu_alloc_display(surface, width, height, linesize,
1283
                       qemu_default_pixelformat(32), 0);
1292 1284
    return surface;
1293 1285
}
1294 1286

  
1295 1287
static DisplaySurface* defaultallocator_resize_displaysurface(DisplaySurface *surface,
1296 1288
                                          int width, int height)
1297 1289
{
1290
    int linesize = width * 4;
1291
    qemu_alloc_display(surface, width, height, linesize,
1292
                       qemu_default_pixelformat(32), 0);
1293
    return surface;
1294
}
1295

  
1296
void qemu_alloc_display(DisplaySurface *surface, int width, int height,
1297
                        int linesize, PixelFormat pf, int newflags)
1298
{
1299
    void *data;
1298 1300
    surface->width = width;
1299 1301
    surface->height = height;
1300
    surface->linesize = width * 4;
1301
    surface->pf = qemu_default_pixelformat(32);
1302
    if (surface->flags & QEMU_ALLOCATED_FLAG)
1303
        surface->data = (uint8_t*) qemu_realloc(surface->data, surface->linesize * surface->height);
1304
    else
1305
        surface->data = (uint8_t*) qemu_malloc(surface->linesize * surface->height);
1302
    surface->linesize = linesize;
1303
    surface->pf = pf;
1304
    if (surface->flags & QEMU_ALLOCATED_FLAG) {
1305
        data = qemu_realloc(surface->data,
1306
                            surface->linesize * surface->height);
1307
    } else {
1308
        data = qemu_malloc(surface->linesize * surface->height);
1309
    }
1310
    surface->data = (uint8_t *)data;
1311
    surface->flags = newflags | QEMU_ALLOCATED_FLAG;
1306 1312
#ifdef HOST_WORDS_BIGENDIAN
1307
    surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;
1308
#else
1309
    surface->flags = QEMU_ALLOCATED_FLAG;
1313
    surface->flags |= QEMU_BIG_ENDIAN_FLAG;
1310 1314
#endif
1311

  
1312
    return surface;
1313 1315
}
1314 1316

  
1315 1317
DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp,
b/console.h
189 189
DisplayState *get_displaystate(void);
190 190
DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp,
191 191
                                                int linesize, uint8_t *data);
192
void qemu_alloc_display(DisplaySurface *surface, int width, int height,
193
                        int linesize, PixelFormat pf, int newflags);
192 194
PixelFormat qemu_different_endianness_pixelformat(int bpp);
193 195
PixelFormat qemu_default_pixelformat(int bpp);
194 196

  
b/ui/sdl.c
176 176

  
177 177
    surface->width = width;
178 178
    surface->height = height;
179
    
179

  
180 180
    if (scaling_active) {
181
        int linesize;
182
        PixelFormat pf;
181 183
        if (host_format.BytesPerPixel != 2 && host_format.BytesPerPixel != 4) {
182
            surface->linesize = width * 4;
183
            surface->pf = qemu_default_pixelformat(32);
184
            linesize = width * 4;
185
            pf = qemu_default_pixelformat(32);
184 186
        } else {
185
            surface->linesize = width * host_format.BytesPerPixel;
186
            surface->pf = sdl_to_qemu_pixelformat(&host_format);
187
            linesize = width * host_format.BytesPerPixel;
188
            pf = sdl_to_qemu_pixelformat(&host_format);
187 189
        }
188
#ifdef HOST_WORDS_BIGENDIAN
189
        surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;
190
#else
191
        surface->flags = QEMU_ALLOCATED_FLAG;
192
#endif
193
        surface->data = (uint8_t*) qemu_mallocz(surface->linesize * surface->height);
194

  
190
        qemu_alloc_display(surface, width, height, linesize, pf, 0);
195 191
        return surface;
196 192
    }
197 193

  

Also available in: Unified diff