mirror of
				https://git.eden-emu.dev/eden-emu/eden.git
				synced 2025-10-25 23:43:17 +00:00 
			
		
		
		
	service/vi/vi_layer: Convert Layer struct into a class
Like the previous changes made to the Display struct, this prepares the Layer struct for changes to its interface. Given Layer will be given more invariants in the future, we convert it into a class to better signify that.
This commit is contained in:
		
							parent
							
								
									00b5069249
								
							
						
					
					
						commit
						55f3ddb276
					
				
					 6 changed files with 43 additions and 10 deletions
				
			
		|  | @ -48,7 +48,7 @@ void Display::CreateLayer(u64 id, std::shared_ptr<NVFlinger::BufferQueue> buffer | |||
| 
 | ||||
| Layer* Display::FindLayer(u64 id) { | ||||
|     const auto itr = std::find_if(layers.begin(), layers.end(), | ||||
|                                   [id](const VI::Layer& layer) { return layer.id == id; }); | ||||
|                                   [id](const VI::Layer& layer) { return layer.GetID() == id; }); | ||||
| 
 | ||||
|     if (itr == layers.end()) { | ||||
|         return nullptr; | ||||
|  | @ -59,7 +59,7 @@ Layer* Display::FindLayer(u64 id) { | |||
| 
 | ||||
| const Layer* Display::FindLayer(u64 id) const { | ||||
|     const auto itr = std::find_if(layers.begin(), layers.end(), | ||||
|                                   [id](const VI::Layer& layer) { return layer.id == id; }); | ||||
|                                   [id](const VI::Layer& layer) { return layer.GetID() == id; }); | ||||
| 
 | ||||
|     if (itr == layers.end()) { | ||||
|         return nullptr; | ||||
|  |  | |||
|  | @ -16,7 +16,7 @@ class BufferQueue; | |||
| 
 | ||||
| namespace Service::VI { | ||||
| 
 | ||||
| struct Layer; | ||||
| class Layer; | ||||
| 
 | ||||
| /// Represents a single display type
 | ||||
| class Display { | ||||
|  |  | |||
|  | @ -2,12 +2,16 @@ | |||
| // Licensed under GPLv2 or any later version
 | ||||
| // Refer to the license.txt file included.
 | ||||
| 
 | ||||
| #include "common/assert.h" | ||||
| #include "core/hle/service/vi/layer/vi_layer.h" | ||||
| 
 | ||||
| namespace Service::VI { | ||||
| 
 | ||||
| Layer::Layer(u64 id, std::shared_ptr<NVFlinger::BufferQueue> queue) | ||||
|     : id{id}, buffer_queue{std::move(queue)} {} | ||||
|     : id{id}, buffer_queue{std::move(queue)} | ||||
| { | ||||
|     ASSERT_MSG(buffer_queue != nullptr, "buffer_queue may not be null."); | ||||
| } | ||||
| 
 | ||||
| Layer::~Layer() = default; | ||||
| 
 | ||||
|  |  | |||
|  | @ -14,10 +14,39 @@ class BufferQueue; | |||
| 
 | ||||
| namespace Service::VI { | ||||
| 
 | ||||
| struct Layer { | ||||
| /// Represents a single display layer.
 | ||||
| class Layer { | ||||
| public: | ||||
|     /// Constructs a layer with a given ID and buffer queue.
 | ||||
|     ///
 | ||||
|     /// @param id    The ID to assign to this layer.
 | ||||
|     /// @param queue The buffer queue for this layer to use.
 | ||||
|     ///
 | ||||
|     Layer(u64 id, std::shared_ptr<NVFlinger::BufferQueue> queue); | ||||
|     ~Layer(); | ||||
| 
 | ||||
|     Layer(const Layer&) = delete; | ||||
|     Layer& operator=(const Layer&) = delete; | ||||
| 
 | ||||
|     Layer(Layer&&) = default; | ||||
|     Layer& operator=(Layer&&) = default; | ||||
| 
 | ||||
|     /// Gets the ID for this layer.
 | ||||
|     u64 GetID() const { | ||||
|         return id; | ||||
|     } | ||||
| 
 | ||||
|     /// Gets a reference to the buffer queue this layer is using.
 | ||||
|     NVFlinger::BufferQueue& GetBufferQueue() { | ||||
|         return *buffer_queue; | ||||
|     } | ||||
| 
 | ||||
|     /// Gets a const reference to the buffer queue this layer is using.
 | ||||
|     const NVFlinger::BufferQueue& GetBufferQueue() const { | ||||
|         return *buffer_queue; | ||||
|     } | ||||
| 
 | ||||
| private: | ||||
|     u64 id; | ||||
|     std::shared_ptr<NVFlinger::BufferQueue> buffer_queue; | ||||
| }; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lioncash
						Lioncash