1 diff -ur skia.org/tools/sk_app/MetalWindowContext.h skia/tools/sk_app/MetalWindowContext.h
2 --- skia.org/tools/sk_app/MetalWindowContext.h 2023-07-08 21:49:27.179700423 +0200
3 +++ skia/tools/sk_app/MetalWindowContext.h 2023-07-08 21:51:53.416328675 +0200
6 static void checkDestroyShared();
8 - void onSwapBuffers() override;
9 + void onSwapBuffers(const SkIRect* rect = nullptr) override;
13 diff -ur skia.org/tools/sk_app/MetalWindowContext.mm skia/tools/sk_app/MetalWindowContext.mm
14 --- skia.org/tools/sk_app/MetalWindowContext.mm 2023-07-08 21:49:27.179700423 +0200
15 +++ skia/tools/sk_app/MetalWindowContext.mm 2023-07-08 21:52:10.064396318 +0200
20 -void MetalWindowContext::onSwapBuffers() {
21 +void MetalWindowContext::onSwapBuffers(const SkIRect*) {
22 id<CAMetalDrawable> currentDrawable = (id<CAMetalDrawable>)fDrawableHandle;
24 id<MTLCommandBuffer> commandBuffer([*fShared->fQueue commandBuffer]);
25 diff -ur skia.org/tools/sk_app/unix/RasterWindowContext_unix.cpp skia/tools/sk_app/unix/RasterWindowContext_unix.cpp
26 --- skia.org/tools/sk_app/unix/RasterWindowContext_unix.cpp 2023-07-08 21:49:27.183700444 +0200
27 +++ skia/tools/sk_app/unix/RasterWindowContext_unix.cpp 2023-07-08 21:54:06.840852252 +0200
29 void setDisplayParams(const DisplayParams& params) override;
32 - void onSwapBuffers() override;
33 + void onSwapBuffers(const SkIRect* rect = nullptr) override;
35 sk_sp<SkSurface> fBackbufferSurface;
39 sk_sp<SkSurface> RasterWindowContext_xlib::getBackbufferSurface() { return fBackbufferSurface; }
41 -void RasterWindowContext_xlib::onSwapBuffers() {
42 +void RasterWindowContext_xlib::onSwapBuffers(const SkIRect* rect) {
44 if (!fBackbufferSurface->peekPixels(&pm)) {
47 if (!XInitImage(&image)) {
50 - XPutImage(fDisplay, fWindow, fGC, &image, 0, 0, 0, 0, pm.width(), pm.height());
51 + SkIRect update = rect ? *rect : SkIRect::MakeWH( pm.width(), pm.height());
52 + XPutImage(fDisplay, fWindow, fGC, &image, update.x(), update.y(),
53 + update.x(), update.y(), update.width(), update.height());
56 } // anonymous namespace
57 diff -ur skia.org/tools/sk_app/VulkanWindowContext.cpp skia/tools/sk_app/VulkanWindowContext.cpp
58 --- skia.org/tools/sk_app/VulkanWindowContext.cpp 2023-07-08 21:49:27.179700423 +0200
59 +++ skia/tools/sk_app/VulkanWindowContext.cpp 2023-07-08 21:52:53.676570245 +0200
61 return sk_ref_sp(surface);
64 -void VulkanWindowContext::onSwapBuffers() {
65 +void VulkanWindowContext::onSwapBuffers(const SkIRect*) {
67 BackbufferInfo* backbuffer = fBackbuffers + fCurrentBackbufferIndex;
68 sk_sp<SkSurface> surface = fSurfaces[backbuffer->fImageIndex];
69 diff -ur skia.org/tools/sk_app/VulkanWindowContext.h skia/tools/sk_app/VulkanWindowContext.h
70 --- skia.org/tools/sk_app/VulkanWindowContext.h 2023-07-08 21:49:27.179700423 +0200
71 +++ skia/tools/sk_app/VulkanWindowContext.h 2023-07-08 21:52:34.580494658 +0200
73 bool createSwapchain(int width, int height, const DisplayParams& params);
74 bool createBuffers(VkFormat format, VkImageUsageFlags, SkColorType colorType, VkSharingMode);
75 void destroyBuffers();
76 - void onSwapBuffers() override;
77 + void onSwapBuffers(const SkIRect* rect = nullptr) override;
80 CreateVkSurfaceFn fCreateVkSurfaceFn;
81 diff -ur skia.org/tools/sk_app/win/RasterWindowContext_win.cpp skia/tools/sk_app/win/RasterWindowContext_win.cpp
82 --- skia.org/tools/sk_app/win/RasterWindowContext_win.cpp 2023-07-08 21:49:27.183700444 +0200
83 +++ skia/tools/sk_app/win/RasterWindowContext_win.cpp 2023-07-08 21:55:26.169145828 +0200
85 void setDisplayParams(const DisplayParams& params) override;
88 - void onSwapBuffers() override;
89 + void onSwapBuffers(const SkIRect* rect=nullptr) override;
91 SkAutoMalloc fSurfaceMemory;
92 sk_sp<SkSurface> fBackbufferSurface;
95 sk_sp<SkSurface> RasterWindowContext_win::getBackbufferSurface() { return fBackbufferSurface; }
97 -void RasterWindowContext_win::onSwapBuffers() {
98 +void RasterWindowContext_win::onSwapBuffers(const SkIRect* rect) {
99 BITMAPINFO* bmpInfo = reinterpret_cast<BITMAPINFO*>(fSurfaceMemory.get());
100 HDC dc = GetDC(fWnd);
102 fBackbufferSurface->peekPixels(&pixmap);
103 - StretchDIBits(dc, 0, 0, fWidth, fHeight, 0, 0, fWidth, fHeight, pixmap.addr(), bmpInfo,
104 - DIB_RGB_COLORS, SRCCOPY);
105 + SkIRect update = rect ? *rect : SkIRect::MakeWH( fWidth, fHeight );
106 + // It appears that y-axis handling is broken if it doesn't match the window size.
107 + update = SkIRect::MakeXYWH( update.x(), 0, update.width(), fHeight );
108 + StretchDIBits(dc, update.x(), update.y(), update.width(), update.height(),
109 + update.x(), update.y(), update.width(), update.height(),
110 + pixmap.addr(), bmpInfo, DIB_RGB_COLORS, SRCCOPY);
114 diff -ur skia.org/tools/sk_app/WindowContext.cpp skia/tools/sk_app/WindowContext.cpp
115 --- skia.org/tools/sk_app/WindowContext.cpp 2023-07-08 21:49:27.179700423 +0200
116 +++ skia/tools/sk_app/WindowContext.cpp 2023-07-08 21:56:23.373350669 +0200
119 WindowContext::~WindowContext() {}
121 -void WindowContext::swapBuffers() {
122 +void WindowContext::swapBuffers(const SkIRect* rect) {
123 #if defined(SK_GRAPHITE)
124 if (fGraphiteContext) {
125 SkASSERT(fGraphiteRecorder);
130 - this->onSwapBuffers();
131 + this->onSwapBuffers(rect);
135 diff -ur skia.org/tools/sk_app/WindowContext.h skia/tools/sk_app/WindowContext.h
136 --- skia.org/tools/sk_app/WindowContext.h 2023-07-08 21:49:27.179700423 +0200
137 +++ skia/tools/sk_app/WindowContext.h 2023-07-08 21:51:08.804143750 +0200
140 virtual sk_sp<SkSurface> getBackbufferSurface() = 0;
142 - void swapBuffers();
143 + void swapBuffers(const SkIRect* rect = nullptr);
145 virtual bool isValid() = 0;
149 virtual bool isGpuContext() { return true; }
151 - virtual void onSwapBuffers() = 0;
152 + virtual void onSwapBuffers(const SkIRect* rect = nullptr) = 0;
154 sk_sp<GrDirectContext> fContext;
155 #if defined(SK_GRAPHITE)