1 diff -ur skia.org/tools/window/win/RasterWindowContext_win.cpp skia/tools/window/win/RasterWindowContext_win.cpp
2 --- skia.org/tools/window/win/RasterWindowContext_win.cpp 2024-10-04 15:36:01.287777189 +0200
3 +++ skia/tools/window/win/RasterWindowContext_win.cpp 2024-10-04 15:37:22.221265385 +0200
7 fBackbufferSurface.reset();
8 - const size_t bmpSize = sizeof(BITMAPINFOHEADER) + w * h * sizeof(uint32_t);
9 + const size_t bmpSize = sizeof(BITMAPINFO);
10 fSurfaceMemory.reset(bmpSize);
11 BITMAPINFO* bmpInfo = reinterpret_cast<BITMAPINFO*>(fSurfaceMemory.get());
12 ZeroMemory(bmpInfo, sizeof(BITMAPINFO));
14 bmpInfo->bmiHeader.biPlanes = 1;
15 bmpInfo->bmiHeader.biBitCount = 32;
16 bmpInfo->bmiHeader.biCompression = BI_RGB;
17 - void* pixels = bmpInfo->bmiColors;
18 + // Do not use a packed DIB bitmap, SkSurface_Raster::onNewImageSnapshot() does
19 + // a deep copy if it does not own the pixels.
21 SkImageInfo info = SkImageInfo::Make(w, h, fDisplayParams.fColorType, kPremul_SkAlphaType,
22 fDisplayParams.fColorSpace);
23 - fBackbufferSurface = SkSurfaces::WrapPixels(info, pixels, sizeof(uint32_t) * w);
24 + fBackbufferSurface = SkSurfaces::Raster(info);
27 sk_sp<SkSurface> RasterWindowContext_win::getBackbufferSurface() { return fBackbufferSurface; }
29 void RasterWindowContext_win::onSwapBuffers() {
30 BITMAPINFO* bmpInfo = reinterpret_cast<BITMAPINFO*>(fSurfaceMemory.get());
32 - StretchDIBits(dc, 0, 0, fWidth, fHeight, 0, 0, fWidth, fHeight, bmpInfo->bmiColors, bmpInfo,
33 - DIB_RGB_COLORS, SRCCOPY);
35 + fBackbufferSurface->peekPixels(&pixmap);
36 + StretchDIBits(dc, 0, 0, fWidth, fHeight, 0, 0, fWidth, fHeight, pixmap.addr(), bmpInfo,
37 + DIB_RGB_COLORS, SRCCOPY);