From 3dc48d26f471fd5e2dd419a73f419a138906605d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Mon, 9 Dec 2019 20:18:27 +0100 Subject: [PATCH] win_d2d: lazy initialization of d2d_bitmap --- src/win/win_d2d.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/win/win_d2d.cpp b/src/win/win_d2d.cpp index ded97dd9f..5a3c9b40f 100644 --- a/src/win/win_d2d.cpp +++ b/src/win/win_d2d.cpp @@ -1,4 +1,4 @@ -/* +/* * 86Box A hypervisor and IBM PC system emulator that specializes in * running old operating systems and software designed for IBM * PC systems and compatibles from 1981 through fairly recent @@ -224,11 +224,21 @@ d2d_blit(int x, int y, int y1, int y2, int w, int h) return; } - rectU = D2D1::RectU(x, y + y1, x + w, y + y2); - hr = d2d_bitmap->CopyFromMemory( - &rectU, - &(render_buffer->line[y + y1][x]), - render_buffer->w << 2); + if (d2d_bitmap == NULL) { + // Create a bitmap for storing intermediate data + hr = d2d_hwndRT->CreateBitmap( + D2D1::SizeU(render_buffer->w, render_buffer->h), + D2D1::BitmapProperties(D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE)), + &d2d_bitmap); + } + + if (SUCCEEDED(hr)) { + rectU = D2D1::RectU(x, y + y1, x + w, y + y2); + hr = d2d_bitmap->CopyFromMemory( + &rectU, + &(render_buffer->line[y + y1][x]), + render_buffer->w << 2); + } video_blit_complete(); @@ -406,15 +416,6 @@ d2d_init_common(int fs) D2D1::RenderTargetProperties(), props, &d2d_hwndRT); - } - - if (SUCCEEDED(hr)) - { - // Create a bitmap for storing intermediate data - hr = d2d_hwndRT->CreateBitmap( - D2D1::SizeU(2048, 2048), - D2D1::BitmapProperties(D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE)), - &d2d_bitmap); } if (SUCCEEDED(hr))