cast row & col to byte
This commit is contained in:
parent
6333a95b25
commit
0206cc8ad6
1 changed files with 16 additions and 10 deletions
|
|
@ -17,6 +17,8 @@ public static class Tile
|
|||
{
|
||||
if( !TryParseRect(request.CanvasRect, out int minRow, out int maxRow, out int minCol, out int maxCol) )
|
||||
throw new ArgumentException($"Invalid canvas_rect: '{request.CanvasRect}'");
|
||||
if( maxRow > byte.MaxValue || maxCol > byte.MaxValue )
|
||||
throw new NotSupportedException($"Unsupported rect row: {maxRow}, col: {maxCol}");
|
||||
|
||||
logger.ZLogDebug(
|
||||
$"rect: {request.CanvasRect}, minRow: {minRow}, maxRow: {maxRow}, minCol: {minCol}, maxCol: {maxCol}");
|
||||
|
|
@ -38,16 +40,20 @@ public static class Tile
|
|||
bool canBeCached = ( predictedW * predictedH ) <= MAX_CACHED_TILE_SIZE;
|
||||
if( canBeCached )
|
||||
{
|
||||
Span<byte> buffer = stackalloc byte[36];
|
||||
MemoryMarshal.Write(buffer, in minRow);
|
||||
MemoryMarshal.Write(buffer[4..], in maxRow);
|
||||
MemoryMarshal.Write(buffer[8..], in minCol);
|
||||
MemoryMarshal.Write(buffer[12..], in maxCol);
|
||||
MemoryMarshal.Write(buffer[16..], in cropOffsetX);
|
||||
MemoryMarshal.Write(buffer[20..], in cropOffsetY);
|
||||
MemoryMarshal.Write(buffer[24..], in cropSizeW);
|
||||
MemoryMarshal.Write(buffer[28..], in cropSizeH);
|
||||
MemoryMarshal.Write(buffer[32..], in outputScale);
|
||||
Span<byte> buffer = stackalloc byte[24];
|
||||
byte minRowByte = (byte)minRow;
|
||||
byte maxRowByte = (byte)maxRow;
|
||||
byte minColByte = (byte)minCol;
|
||||
byte maxColByte = (byte)maxCol;
|
||||
MemoryMarshal.Write(buffer, in minRowByte);
|
||||
MemoryMarshal.Write(buffer[1..], in maxRowByte);
|
||||
MemoryMarshal.Write(buffer[2..], in minColByte);
|
||||
MemoryMarshal.Write(buffer[3..], in maxColByte);
|
||||
MemoryMarshal.Write(buffer[4..], in cropOffsetX);
|
||||
MemoryMarshal.Write(buffer[8..], in cropOffsetY);
|
||||
MemoryMarshal.Write(buffer[12..], in cropSizeW);
|
||||
MemoryMarshal.Write(buffer[16..], in cropSizeH);
|
||||
MemoryMarshal.Write(buffer[20..], in outputScale);
|
||||
cacheKey = Convert.ToHexString(buffer).ToLowerInvariant();
|
||||
if( cache.TryGetValue(cacheKey, out cacheFile) && File.Exists(cacheFile) )
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue