mirror of
				https://github.com/yuzu-emu/FasTC.git
				synced 2025-11-04 14:15:00 +00:00 
			
		
		
		
	Add 4-value pixel constructor
This commit is contained in:
		
							parent
							
								
									f0110360c4
								
							
						
					
					
						commit
						86678c0cfe
					
				| 
						 | 
				
			
			@ -70,6 +70,13 @@ class Pixel : public Vector4<uint16> {
 | 
			
		|||
      m_BitDepth[i] = 8;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Pixel(ChannelType a, ChannelType r, ChannelType g, ChannelType b, unsigned bitDepth = 8)
 | 
			
		||||
    : VectorType(a, r, g, b)
 | 
			
		||||
  {
 | 
			
		||||
    for(int i = 0; i < 4; i++)
 | 
			
		||||
      m_BitDepth[i] = bitDepth;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  explicit Pixel(uint32 rgba) : VectorType() {
 | 
			
		||||
    for(int i = 0; i < 4; i++)
 | 
			
		||||
      m_BitDepth[i] = 8;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -68,6 +68,33 @@ TEST(Pixel, DefaultConstructor) {
 | 
			
		|||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST(Pixel, FourWideConstructor) {
 | 
			
		||||
  FasTC::Pixel p(1, 2, 3, 4);
 | 
			
		||||
  EXPECT_EQ(p.R(), 2);
 | 
			
		||||
  EXPECT_EQ(p.G(), 3);
 | 
			
		||||
  EXPECT_EQ(p.B(), 4);
 | 
			
		||||
  EXPECT_EQ(p.A(), 1);
 | 
			
		||||
 | 
			
		||||
  uint8 depth[4];
 | 
			
		||||
  p.GetBitDepth(depth);
 | 
			
		||||
 | 
			
		||||
  for(int i = 0; i < 4; i++) {
 | 
			
		||||
    EXPECT_EQ(depth[i], 8);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  FasTC::Pixel q(static_cast<uint16>(1 << 16), 6, -2, 5, 4);
 | 
			
		||||
  EXPECT_EQ(q.R(), 6);
 | 
			
		||||
  EXPECT_EQ(q.G(), static_cast<uint16>(-2));
 | 
			
		||||
  EXPECT_EQ(q.B(), 5);
 | 
			
		||||
  EXPECT_EQ(q.A(), 0);
 | 
			
		||||
 | 
			
		||||
  q.GetBitDepth(depth);
 | 
			
		||||
 | 
			
		||||
  for(int i = 0; i < 4; i++) {
 | 
			
		||||
    EXPECT_EQ(depth[i], 4);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST(Pixel, FromBitsAndAssociatedConstructor) {
 | 
			
		||||
  const uint8 bits[8] = { 0xA8, 0xB3, 0x7C, 0x21, 0xBD, 0xD4, 0x09, 0x92 };
 | 
			
		||||
  FasTC::Pixel ps[2];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue