forked from quickshell/quickshell
		
	wayland/screencopy: reset buffer requests between frames
Prevents buffer requests from collecting a huge set of duplicate dmabuf and shm formats.
This commit is contained in:
		
							parent
							
								
									448623de5a
								
							
						
					
					
						commit
						ab096b7e78
					
				
					 4 changed files with 10 additions and 1 deletions
				
			
		| 
						 | 
					@ -22,6 +22,8 @@ namespace {
 | 
				
			||||||
QS_LOGGING_CATEGORY(logBuffer, "quickshell.wayland.buffer", QtWarningMsg);
 | 
					QS_LOGGING_CATEGORY(logBuffer, "quickshell.wayland.buffer", QtWarningMsg);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void WlBufferRequest::reset() { *this = WlBufferRequest(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WlBuffer* WlBufferSwapchain::createBackbuffer(const WlBufferRequest& request, bool* newBuffer) {
 | 
					WlBuffer* WlBufferSwapchain::createBackbuffer(const WlBufferRequest& request, bool* newBuffer) {
 | 
				
			||||||
	auto& buffer = this->presentSecondBuffer ? this->buffer1 : this->buffer2;
 | 
						auto& buffer = this->presentSecondBuffer ? this->buffer1 : this->buffer2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -53,7 +55,8 @@ bool WlBufferManager::isReady() const { return this->p->mReady; }
 | 
				
			||||||
	                             << " (disabled: " << dmabufDisabled << ')';
 | 
						                             << " (disabled: " << dmabufDisabled << ')';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (const auto& [format, modifiers]: request.dmabuf.formats) {
 | 
						for (const auto& [format, modifiers]: request.dmabuf.formats) {
 | 
				
			||||||
		qCDebug(logBuffer) << "    Format" << dmabuf::FourCCStr(format);
 | 
							qCDebug(logBuffer).nospace() << "    Format " << dmabuf::FourCCStr(format)
 | 
				
			||||||
 | 
							                             << (modifiers.length() == 0 ? " (No modifiers specified)" : "");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		for (const auto& modifier: modifiers) {
 | 
							for (const auto& modifier: modifiers) {
 | 
				
			||||||
			qCDebug(logBuffer) << "      Explicit Modifier" << dmabuf::FourCCModStr(modifier);
 | 
								qCDebug(logBuffer) << "      Explicit Modifier" << dmabuf::FourCCModStr(modifier);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -68,6 +68,8 @@ struct WlBufferRequest {
 | 
				
			||||||
		dev_t device = 0;
 | 
							dev_t device = 0;
 | 
				
			||||||
		StackList<DmaFormat, 1> formats;
 | 
							StackList<DmaFormat, 1> formats;
 | 
				
			||||||
	} dmabuf;
 | 
						} dmabuf;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void reset();
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class WlBuffer {
 | 
					class WlBuffer {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -64,6 +64,8 @@ void HyprlandScreencopyContext::onToplevelDestroyed() {
 | 
				
			||||||
void HyprlandScreencopyContext::captureFrame() {
 | 
					void HyprlandScreencopyContext::captureFrame() {
 | 
				
			||||||
	if (this->object()) return;
 | 
						if (this->object()) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this->request.reset();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this->init(this->manager->capture_toplevel_with_wlr_toplevel_handle(
 | 
						this->init(this->manager->capture_toplevel_with_wlr_toplevel_handle(
 | 
				
			||||||
	    this->paintCursors ? 1 : 0,
 | 
						    this->paintCursors ? 1 : 0,
 | 
				
			||||||
	    this->handle->object()
 | 
						    this->handle->object()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -65,6 +65,8 @@ void WlrScreencopyContext::onScreenDestroyed() {
 | 
				
			||||||
void WlrScreencopyContext::captureFrame() {
 | 
					void WlrScreencopyContext::captureFrame() {
 | 
				
			||||||
	if (this->object()) return;
 | 
						if (this->object()) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this->request.reset();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (this->region.isEmpty()) {
 | 
						if (this->region.isEmpty()) {
 | 
				
			||||||
		this->init(manager->capture_output(this->paintCursors ? 1 : 0, screen->output()));
 | 
							this->init(manager->capture_output(this->paintCursors ? 1 : 0, screen->output()));
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue