MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / AllocateBackingStore

Method AllocateBackingStore

src/video/win32_v.cpp:1140–1176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1138}
1139
1140bool VideoDriver_Win32GDI::AllocateBackingStore(int w, int h, bool force)
1141{
1142 uint bpp = BlitterFactory::GetCurrentBlitter()->GetScreenDepth();
1143
1144 w = std::max(w, 64);
1145 h = std::max(h, 64);
1146
1147 if (!force && w == _screen.width && h == _screen.height) return false;
1148
1149 BITMAPINFO *bi = (BITMAPINFO *)new char[sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256]();
1150 bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
1151
1152 bi->bmiHeader.biWidth = this->width = w;
1153 bi->bmiHeader.biHeight = -(this->height = h);
1154
1155 bi->bmiHeader.biPlanes = 1;
1156 bi->bmiHeader.biBitCount = bpp;
1157 bi->bmiHeader.biCompression = BI_RGB;
1158
1159 if (this->dib_sect) DeleteObject(this->dib_sect);
1160
1161 HDC dc = GetDC(0);
1162 this->dib_sect = CreateDIBSection(dc, bi, DIB_RGB_COLORS, (VOID **)&this->buffer_bits, nullptr, 0);
1163 if (this->dib_sect == nullptr) {
1164 delete[] bi;
1165 UserError("CreateDIBSection failed");
1166 }
1167 ReleaseDC(0, dc);
1168
1169 _screen.width = w;
1170 _screen.pitch = (bpp == 8) ? Align(w, 4) : w;
1171 _screen.height = h;
1172 _screen.dst_ptr = this->GetVideoPointer();
1173
1174 delete[] bi;
1175 return true;
1176}
1177
1178bool VideoDriver_Win32GDI::AfterBlitterChange()
1179{

Callers 4

StartMethod · 0.95
AfterBlitterChangeMethod · 0.95
ClientSizeChangedMethod · 0.45
ClientSizeChangedMethod · 0.45

Calls 6

GetVideoPointerMethod · 0.95
ReleaseVideoPointerMethod · 0.95
GetVideoPointerMethod · 0.95
AlignFunction · 0.85
GetScreenDepthMethod · 0.45
ResizeMethod · 0.45

Tested by

no test coverage detected