Bump version to 24.04.3.4
[LibreOffice.git] / external / skia / windows-raster-surface-no-copies.patch.1
blob3765f70971fd6711b7143b69302f6a8b5ac74dfc
1 diff --git a/tools/sk_app/win/RasterWindowContext_win.cpp b/tools/sk_app/win/RasterWindowContext_win.cpp
2 index 9548220ce6..49f1f9ed17 100644
3 --- a/tools/sk_app/win/RasterWindowContext_win.cpp
4 +++ b/tools/sk_app/win/RasterWindowContext_win.cpp
5 @@ -53,7 +53,7 @@
6      fWidth = w;
7      fHeight = h;
8      fBackbufferSurface.reset();
9 -    const size_t bmpSize = sizeof(BITMAPINFOHEADER) + w * h * sizeof(uint32_t);
10 +    const size_t bmpSize = sizeof(BITMAPINFO);
11      fSurfaceMemory.reset(bmpSize);
12      BITMAPINFO* bmpInfo = reinterpret_cast<BITMAPINFO*>(fSurfaceMemory.get());
13      ZeroMemory(bmpInfo, sizeof(BITMAPINFO));
14 @@ -63,11 +63,12 @@
15      bmpInfo->bmiHeader.biPlanes = 1;
16      bmpInfo->bmiHeader.biBitCount = 32;
17      bmpInfo->bmiHeader.biCompression = BI_RGB;
18 -    void* pixels = bmpInfo->bmiColors;
19 +    // Do not use a packed DIB bitmap, SkSurface_Raster::onNewImageSnapshot() does
20 +    // a deep copy if it does not own the pixels.
22      SkImageInfo info = SkImageInfo::Make(w, h, fDisplayParams.fColorType, kPremul_SkAlphaType,
23                                           fDisplayParams.fColorSpace);
24 -    fBackbufferSurface = SkSurfaces::WrapPixels(info, pixels, sizeof(uint32_t) * w);
25 +    fBackbufferSurface = SkSurfaces::Raster(info);
26  }
28  sk_sp<SkSurface> RasterWindowContext_win::getBackbufferSurface() { return fBackbufferSurface; }
29 @@ -75,8 +76,10 @@
30  void RasterWindowContext_win::onSwapBuffers() {
31      BITMAPINFO* bmpInfo = reinterpret_cast<BITMAPINFO*>(fSurfaceMemory.get());
32      HDC dc = GetDC(fWnd);
33 -    StretchDIBits(dc, 0, 0, fWidth, fHeight, 0, 0, fWidth, fHeight, bmpInfo->bmiColors, bmpInfo,
34 -                  DIB_RGB_COLORS, SRCCOPY);
35 +    SkPixmap pixmap;
36 +    fBackbufferSurface->peekPixels(&pixmap);
37 +    StretchDIBits(dc, 0, 0, fWidth, fHeight, 0, 0, fWidth, fHeight, pixmap.addr(), bmpInfo,
38 +                   DIB_RGB_COLORS, SRCCOPY);
39      ReleaseDC(fWnd, dc);
40  }