1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
diff -ur skia.org/tools/window/MetalWindowContext.h skia/tools/window/MetalWindowContext.h
--- skia.org/tools/window/MetalWindowContext.h 2024-10-05 18:16:04.521814026 +0200
+++ skia/tools/window/MetalWindowContext.h 2024-10-05 18:16:49.459152416 +0200
@@ -51,7 +51,7 @@
static void checkDestroyShared();
- void onSwapBuffers() override;
+ void onSwapBuffers(const SkIRect* rect = nullptr) override;
bool fValid;
diff -ur skia.org/tools/window/MetalWindowContext.mm skia/tools/window/MetalWindowContext.mm
--- skia.org/tools/window/MetalWindowContext.mm 2024-10-05 18:16:04.521814026 +0200
+++ skia/tools/window/MetalWindowContext.mm 2024-10-05 18:17:31.670443188 +0200
@@ -193,7 +193,7 @@
return surface;
}
-void MetalWindowContext::onSwapBuffers() {
+void MetalWindowContext::onSwapBuffers(const SkIRect*) {
id<CAMetalDrawable> currentDrawable = (id<CAMetalDrawable>)fDrawableHandle;
id<MTLCommandBuffer> commandBuffer([*fShared->fQueue commandBuffer]);
diff -ur skia.org/tools/window/unix/RasterWindowContext_unix.cpp skia/tools/window/unix/RasterWindowContext_unix.cpp
--- skia.org/tools/window/unix/RasterWindowContext_unix.cpp 2024-10-05 18:16:04.521814026 +0200
+++ skia/tools/window/unix/RasterWindowContext_unix.cpp 2024-10-05 18:18:49.554847490 +0200
@@ -24,7 +24,7 @@
void setDisplayParams(const DisplayParams& params) override;
protected:
- void onSwapBuffers() override;
+ void onSwapBuffers(const SkIRect* rect = nullptr) override;
sk_sp<SkSurface> fBackbufferSurface;
Display* fDisplay;
@@ -58,7 +58,7 @@
sk_sp<SkSurface> RasterWindowContext_xlib::getBackbufferSurface() { return fBackbufferSurface; }
-void RasterWindowContext_xlib::onSwapBuffers() {
+void RasterWindowContext_xlib::onSwapBuffers(const SkIRect* rect) {
SkPixmap pm;
if (!fBackbufferSurface->peekPixels(&pm)) {
return;
@@ -80,7 +80,9 @@
if (!XInitImage(&image)) {
return;
}
- XPutImage(fDisplay, fWindow, fGC, &image, 0, 0, 0, 0, pm.width(), pm.height());
+ SkIRect update = rect ? *rect : SkIRect::MakeWH( pm.width(), pm.height());
+ XPutImage(fDisplay, fWindow, fGC, &image, update.x(), update.y(),
+ update.x(), update.y(), update.width(), update.height());
}
} // anonymous namespace
diff -ur skia.org/tools/window/VulkanWindowContext.cpp skia/tools/window/VulkanWindowContext.cpp
--- skia.org/tools/window/VulkanWindowContext.cpp 2024-10-05 18:16:04.521814026 +0200
+++ skia/tools/window/VulkanWindowContext.cpp 2024-10-05 18:19:23.074028410 +0200
@@ -542,7 +542,7 @@
return sk_ref_sp(surface);
}
-void VulkanWindowContext::onSwapBuffers() {
+void VulkanWindowContext::onSwapBuffers(const SkIRect*) {
BackbufferInfo* backbuffer = fBackbuffers + fCurrentBackbufferIndex;
SkSurface* surface = fSurfaces[backbuffer->fImageIndex].get();
diff -ur skia.org/tools/window/VulkanWindowContext.h skia/tools/window/VulkanWindowContext.h
--- skia.org/tools/window/VulkanWindowContext.h 2024-10-05 18:16:04.521814026 +0200
+++ skia/tools/window/VulkanWindowContext.h 2024-10-05 18:19:54.713202674 +0200
@@ -70,7 +70,7 @@
bool createSwapchain(int width, int height, const DisplayParams& params);
bool createBuffers(VkFormat format, VkImageUsageFlags, SkColorType colorType, VkSharingMode);
void destroyBuffers();
- void onSwapBuffers() override;
+ void onSwapBuffers(const SkIRect* rect = nullptr) override;
// Create functions
CreateVkSurfaceFn fCreateVkSurfaceFn;
CanPresentFn fCanPresentFn;
diff -ur skia.org/tools/window/win/RasterWindowContext_win.cpp skia/tools/window/win/RasterWindowContext_win.cpp
--- skia.org/tools/window/win/RasterWindowContext_win.cpp 2024-10-05 18:16:04.521814026 +0200
+++ skia/tools/window/win/RasterWindowContext_win.cpp 2024-10-05 18:20:58.138561375 +0200
@@ -27,7 +27,7 @@
void setDisplayParams(const DisplayParams& params) override;
protected:
- void onSwapBuffers() override;
+ void onSwapBuffers(const SkIRect* rect=nullptr) override;
SkAutoMalloc fSurfaceMemory;
sk_sp<SkSurface> fBackbufferSurface;
@@ -73,13 +73,17 @@
sk_sp<SkSurface> RasterWindowContext_win::getBackbufferSurface() { return fBackbufferSurface; }
-void RasterWindowContext_win::onSwapBuffers() {
+void RasterWindowContext_win::onSwapBuffers(const SkIRect* rect) {
BITMAPINFO* bmpInfo = reinterpret_cast<BITMAPINFO*>(fSurfaceMemory.get());
HDC dc = GetDC(fWnd);
SkPixmap pixmap;
fBackbufferSurface->peekPixels(&pixmap);
- StretchDIBits(dc, 0, 0, fWidth, fHeight, 0, 0, fWidth, fHeight, pixmap.addr(), bmpInfo,
- DIB_RGB_COLORS, SRCCOPY);
+ SkIRect update = rect ? *rect : SkIRect::MakeWH( fWidth, fHeight );
+ // It appears that y-axis handling is broken if it doesn't match the window size.
+ update = SkIRect::MakeXYWH( update.x(), 0, update.width(), fHeight );
+ StretchDIBits(dc, update.x(), update.y(), update.width(), update.height(),
+ update.x(), update.y(), update.width(), update.height(),
+ pixmap.addr(), bmpInfo, DIB_RGB_COLORS, SRCCOPY);
ReleaseDC(fWnd, dc);
}
diff -ur skia.org/tools/window/WindowContext.cpp skia/tools/window/WindowContext.cpp
--- skia.org/tools/window/WindowContext.cpp 2024-10-05 18:16:04.521814026 +0200
+++ skia/tools/window/WindowContext.cpp 2024-10-05 18:21:34.482772084 +0200
@@ -20,8 +20,8 @@
WindowContext::~WindowContext() {}
-void WindowContext::swapBuffers() {
- this->onSwapBuffers();
+void WindowContext::swapBuffers(const SkIRect* rect) {
+ this->onSwapBuffers(rect);
}
#if defined(SK_GRAPHITE)
diff -ur skia.org/tools/window/WindowContext.h skia/tools/window/WindowContext.h
--- skia.org/tools/window/WindowContext.h 2024-10-05 18:16:04.521814026 +0200
+++ skia/tools/window/WindowContext.h 2024-10-05 18:22:12.945998819 +0200
@@ -31,7 +31,7 @@
virtual sk_sp<SkSurface> getBackbufferSurface() = 0;
- void swapBuffers();
+ void swapBuffers(const SkIRect* rect = nullptr);
virtual bool isValid() = 0;
@@ -57,7 +57,7 @@
protected:
virtual bool isGpuContext() { return true; }
- virtual void onSwapBuffers() = 0;
+ virtual void onSwapBuffers(const SkIRect* rect = nullptr) = 0;
sk_sp<GrDirectContext> fContext;
#if defined(SK_GRAPHITE)
|