mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 21:42:43 +00:00 
			
		
		
		
	 0423225290
			
		
	
	
		0423225290
		
	
	
	
	
		
			
			A few small changes that didn't seem to deserve separate commits: - Mark it as packed to remove compiler complaints when it's a member of a packed struct. - Add a default constructor for places where we fill in a struct gradually. - Restrict the constructor to exactly 4-character string literals. - Add a to_u32() method for the one place that needs that.
		
			
				
	
	
		
			36 lines
		
	
	
	
		
			690 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
	
		
			690 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| namespace Gfx {
 | |
| 
 | |
| struct [[gnu::packed]] FourCC {
 | |
|     FourCC() = default;
 | |
| 
 | |
|     constexpr FourCC(char const name[4])
 | |
|     {
 | |
|         cc[0] = name[0];
 | |
|         cc[1] = name[1];
 | |
|         cc[2] = name[2];
 | |
|         cc[3] = name[3];
 | |
|     }
 | |
| 
 | |
|     bool operator==(FourCC const&) const = default;
 | |
|     bool operator!=(FourCC const&) const = default;
 | |
| 
 | |
|     u32 to_u32() const
 | |
|     {
 | |
|         return (static_cast<u8>(cc[0]) << 24)
 | |
|             | (static_cast<u8>(cc[1]) << 16)
 | |
|             | (static_cast<u8>(cc[2]) << 8)
 | |
|             | static_cast<u8>(cc[3]);
 | |
|     }
 | |
| 
 | |
|     char cc[4];
 | |
| };
 | |
| 
 | |
| }
 |