remove assert looking for new compatibilityMode DOCX
[LibreOffice.git] / external / skia / windows-raster-surface-no-copies.patch.1
blob9c59c252c1f6c2fa272379a20a1706fc38c39dcb
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
4 @@ -53,7 +53,7 @@
5      fWidth = w;
6      fHeight = h;
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));
13 @@ -63,11 +63,12 @@
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);
25  }
27  sk_sp<SkSurface> RasterWindowContext_win::getBackbufferSurface() { return fBackbufferSurface; }
28 @@ -75,8 +76,10 @@
29  void RasterWindowContext_win::onSwapBuffers() {
30      BITMAPINFO* bmpInfo = reinterpret_cast<BITMAPINFO*>(fSurfaceMemory.get());
31      HDC dc = GetDC(fWnd);
32 -    StretchDIBits(dc, 0, 0, fWidth, fHeight, 0, 0, fWidth, fHeight, bmpInfo->bmiColors, bmpInfo,
33 -                  DIB_RGB_COLORS, SRCCOPY);
34 +    SkPixmap pixmap;
35 +    fBackbufferSurface->peekPixels(&pixmap);
36 +    StretchDIBits(dc, 0, 0, fWidth, fHeight, 0, 0, fWidth, fHeight, pixmap.addr(), bmpInfo,
37 +                   DIB_RGB_COLORS, SRCCOPY);
38      ReleaseDC(fWnd, dc);
39  }