mirror of
				https://github.com/gnif/LookingGlass.git
				synced 2025-10-31 12:42:02 +00:00 
			
		
		
		
	[host] DXGI: implement damage-aware RGB24 copy
This commit is contained in:
		 Tudor Brindus
					Tudor Brindus
				
			
				
					committed by
					
						 Geoffrey McRae
						Geoffrey McRae
					
				
			
			
				
	
			
			
			 Geoffrey McRae
						Geoffrey McRae
					
				
			
						parent
						
							6329779893
						
					
				
				
					commit
					ea5b6b4026
				
			| @@ -140,6 +140,11 @@ static void d3d11_free(void) | ||||
|   this = NULL; | ||||
| } | ||||
|  | ||||
| static int scaleForBGR(int x) | ||||
| { | ||||
|   return x * 3 / 4; | ||||
| } | ||||
|  | ||||
| static void copyFrameFull(Texture * tex, ID3D11Texture2D * src) | ||||
| { | ||||
|   struct D3D11TexImpl * teximpl = TEXIMPL(*tex); | ||||
| @@ -155,11 +160,11 @@ static void copyFrameFull(Texture * tex, ID3D11Texture2D * src) | ||||
|       FrameDamageRect * rect = tex->texDamageRects + i; | ||||
|       D3D11_BOX box = | ||||
|       { | ||||
|         .left   = rect->x, | ||||
|         .left   = scaleForBGR(rect->x), | ||||
|         .top    = rect->y, | ||||
|         .front  = 0, | ||||
|         .back   = 1, | ||||
|         .right  = rect->x + rect->width , | ||||
|         .right  = scaleForBGR(rect->x + rect->width), | ||||
|         .bottom = rect->y + rect->height, | ||||
|       }; | ||||
|       ID3D11DeviceContext_CopySubresourceRegion(*dxgi->deviceContext, | ||||
|   | ||||
| @@ -1365,6 +1365,11 @@ static CaptureResult dxgi_waitFrame(CaptureFrame * frame, const size_t maxFrameS | ||||
|   return CAPTURE_RESULT_OK; | ||||
| } | ||||
|  | ||||
| static int scaleForBGR(int x) | ||||
| { | ||||
|   return x * 3 / 4; | ||||
| } | ||||
|  | ||||
| static CaptureResult dxgi_getFrame(FrameBuffer * frame, int frameIndex) | ||||
| { | ||||
|   DEBUG_ASSERT(this); | ||||
| @@ -1383,7 +1388,19 @@ static CaptureResult dxgi_getFrame(FrameBuffer * frame, int frameIndex) | ||||
|     memcpy(damage->rects + damage->count, tex->damageRects, | ||||
|       tex->damageRectsCount * sizeof(*tex->damageRects)); | ||||
|     damage->count += tex->damageRectsCount; | ||||
|     rectsBufferToFramebuffer(damage->rects, damage->count, this->bpp, frame, | ||||
|  | ||||
|     FrameDamageRect scaledDamageRects[damage->count]; | ||||
|     for (int i = 0; i < ARRAYSIZE(scaledDamageRects); i++) { | ||||
|       FrameDamageRect rect = damage->rects[i]; | ||||
|       int originalX = rect.x; | ||||
|       int scaledX = scaleForBGR(originalX); | ||||
|       rect.x = scaledX; | ||||
|       rect.width = scaleForBGR(originalX + rect.width) - scaledX; | ||||
|  | ||||
|       scaledDamageRects[i] = rect; | ||||
|     } | ||||
|  | ||||
|     rectsBufferToFramebuffer(scaledDamageRects, damage->count, this->bpp, frame, | ||||
|       this->pitch, this->dataHeight, tex->map, this->pitch); | ||||
|   } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user