calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / external / skia / swap-buffers-rect.patch.1
blob628a7e26cd805ea9c445cf66ffe9818dcbcbfaf6
1 diff --git a/tools/sk_app/GLWindowContext.h b/tools/sk_app/GLWindowContext.h
2 index c519903006..5dc5bcd180 100644
3 --- a/tools/sk_app/GLWindowContext.h
4 +++ b/tools/sk_app/GLWindowContext.h
5 @@ -25,7 +25,7 @@ public:
6      bool isValid() override { return SkToBool(fBackendContext.get()); }
7  
8      void resize(int w, int h) override;
9 -    void swapBuffers() override;
10 +    void swapBuffers(const SkIRect* rect = nullptr) override;
12      void setDisplayParams(const DisplayParams& params) override;
14 diff --git a/tools/sk_app/MetalWindowContext.h b/tools/sk_app/MetalWindowContext.h
15 index fbf35c3c2b..2194277922 100644
16 --- a/tools/sk_app/MetalWindowContext.h
17 +++ b/tools/sk_app/MetalWindowContext.h
18 @@ -29,7 +29,7 @@ public:
20      bool isValid() override { return fValid; }
22 -    void swapBuffers() override;
23 +    void swapBuffers(const SkIRect* rect = nullptr) override;
25      void setDisplayParams(const DisplayParams& params) override;
27 diff --git a/tools/sk_app/MetalWindowContext.mm b/tools/sk_app/MetalWindowContext.mm
28 index 49dc77b74d..ca1d74dc6c 100644
29 --- a/tools/sk_app/MetalWindowContext.mm
30 +++ b/tools/sk_app/MetalWindowContext.mm
31 @@ -187,7 +187,7 @@ GrBackendRenderTarget backendRT(fWidth,
32      return surface;
33  }
35 -void MetalWindowContext::swapBuffers() {
36 +void MetalWindowContext::swapBuffers(const SkIRect*) {
37      id<CAMetalDrawable> currentDrawable = (id<CAMetalDrawable>)fDrawableHandle;
39      id<MTLCommandBuffer> commandBuffer([*fShared->fQueue commandBuffer]);
40 diff --git a/tools/sk_app/VulkanWindowContext.cpp b/tools/sk_app/VulkanWindowContext.cpp
41 index 2b36d60076..d73978c9e4 100644
42 --- a/tools/sk_app/VulkanWindowContext.cpp
43 +++ b/tools/sk_app/VulkanWindowContext.cpp
44 @@ -572,7 +572,7 @@ sk_sp<SkSurface> VulkanWindowContext::getBackbufferSurface() {
45      return sk_ref_sp(surface);
46  }
48 -void VulkanWindowContext::swapBuffers() {
49 +void VulkanWindowContext::swapBuffers(const SkIRect*) {
51      BackbufferInfo* backbuffer = fBackbuffers + fCurrentBackbufferIndex;
52      SkSurface* surface = fSurfaces[backbuffer->fImageIndex].get();
53 diff --git a/tools/sk_app/VulkanWindowContext.h b/tools/sk_app/VulkanWindowContext.h
54 index 92bfba6dff..46f7fd97bd 100644
55 --- a/tools/sk_app/VulkanWindowContext.h
56 +++ b/tools/sk_app/VulkanWindowContext.h
57 @@ -32,7 +32,7 @@ public:
58      static GrDirectContext* getSharedGrDirectContext() { return fGlobalShared ? fGlobalShared->fContext.get() : nullptr; }
60      sk_sp<SkSurface> getBackbufferSurface() override;
61 -    void swapBuffers() override;
62 +    void swapBuffers(const SkIRect* rect = nullptr) override;
64      bool isValid() override { return fSurface != VK_NULL_HANDLE; }
66 diff --git a/tools/sk_app/WindowContext.h b/tools/sk_app/WindowContext.h
67 index 68bb84b988..e15c1a3cf3 100644
68 --- a/tools/sk_app/WindowContext.h
69 +++ b/tools/sk_app/WindowContext.h
70 @@ -8,6 +8,7 @@
71  #define WindowContext_DEFINED
73  #include "include/core/SkRefCnt.h"
74 +#include "include/core/SkRect.h"
75  #include "include/core/SkSurfaceProps.h"
76  #include "include/gpu/GrTypes.h"
77  #include "include/gpu/GrDirectContext.h"
78 @@ -25,7 +26,7 @@ public:
80      virtual sk_sp<SkSurface> getBackbufferSurface() = 0;
82 -    virtual void swapBuffers() = 0;
83 +    virtual void swapBuffers(const SkIRect* rect = nullptr) = 0;
85      virtual bool isValid() = 0;
87 diff --git a/tools/sk_app/unix/RasterWindowContext_unix.cpp b/tools/sk_app/unix/RasterWindowContext_unix.cpp
88 index 6ac20962b7..2ea9e07588 100644
89 --- a/tools/sk_app/unix/RasterWindowContext_unix.cpp
90 +++ b/tools/sk_app/unix/RasterWindowContext_unix.cpp
91 @@ -19,7 +19,7 @@ public:
92      RasterWindowContext_xlib(Display*, XWindow, int width, int height, const DisplayParams&);
94      sk_sp<SkSurface> getBackbufferSurface() override;
95 -    void swapBuffers() override;
96 +    void swapBuffers(const SkIRect* rect) override;
97      bool isValid() override { return SkToBool(fWindow); }
98      void resize(int  w, int h) override;
99      void setDisplayParams(const DisplayParams& params) override;
100 @@ -60,7 +60,7 @@ void RasterWindowContext_xlib::resize(int  w, int h) {
102  sk_sp<SkSurface> RasterWindowContext_xlib::getBackbufferSurface() { return fBackbufferSurface; }
104 -void RasterWindowContext_xlib::swapBuffers() {
105 +void RasterWindowContext_xlib::swapBuffers(const SkIRect* rect) {
106      SkPixmap pm;
107      if (!fBackbufferSurface->peekPixels(&pm)) {
108          return;
109 @@ -82,7 +82,9 @@ void RasterWindowContext_xlib::swapBuffers() {
110      if (!XInitImage(&image)) {
111          return;
112      }
113 -    XPutImage(fDisplay, fWindow, fGC, &image, 0, 0, 0, 0, pm.width(), pm.height());
114 +    SkIRect update = rect ? *rect : SkIRect::MakeWH( pm.width(), pm.height());
115 +    XPutImage(fDisplay, fWindow, fGC, &image, update.x(), update.y(),
116 +              update.x(), update.y(), update.width(), update.height());
119  }  // anonymous namespace
120 diff --git a/tools/sk_app/win/RasterWindowContext_win.cpp b/tools/sk_app/win/RasterWindowContext_win.cpp
121 index d80c6fbeec..72df8d5170 100644
122 --- a/tools/sk_app/win/RasterWindowContext_win.cpp
123 +++ b/tools/sk_app/win/RasterWindowContext_win.cpp
124 @@ -22,7 +22,7 @@ public:
125      RasterWindowContext_win(HWND, const DisplayParams&);
127      sk_sp<SkSurface> getBackbufferSurface() override;
128 -    void swapBuffers() override;
129 +    void swapBuffers(const SkIRect* rect) override;
130      bool isValid() override { return SkToBool(fWnd); }
131      void resize(int w, int h) override;
132      void setDisplayParams(const DisplayParams& params) override;
133 @@ -75,13 +75,17 @@ void RasterWindowContext_win::resize(int w, int h) {
135  sk_sp<SkSurface> RasterWindowContext_win::getBackbufferSurface() { return fBackbufferSurface; }
137 -void RasterWindowContext_win::swapBuffers() {
138 +void RasterWindowContext_win::swapBuffers(const SkIRect* rect) {
139      BITMAPINFO* bmpInfo = reinterpret_cast<BITMAPINFO*>(fSurfaceMemory.get());
140      HDC dc = GetDC(fWnd);
141      SkPixmap pixmap;
142      fBackbufferSurface->peekPixels(&pixmap);
143 -    StretchDIBits(dc, 0, 0, fWidth, fHeight, 0, 0, fWidth, fHeight, pixmap.addr(), bmpInfo,
144 -                  DIB_RGB_COLORS, SRCCOPY);
145 +    SkIRect update = rect ? *rect : SkIRect::MakeWH( fWidth, fHeight );
146 +    // It appears that y-axis handling is broken if it doesn't match the window size.
147 +    update = SkIRect::MakeXYWH( update.x(), 0, update.width(), fHeight );
148 +    StretchDIBits(dc, update.x(), update.y(), update.width(), update.height(),
149 +                  update.x(), update.y(), update.width(), update.height(),
150 +                  pixmap.addr(), bmpInfo, DIB_RGB_COLORS, SRCCOPY);
151      ReleaseDC(fWnd, dc);