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) )
|
if( !TryParseRect(request.CanvasRect, out int minRow, out int maxRow, out int minCol, out int maxCol) )
|
||||||
throw new ArgumentException($"Invalid canvas_rect: '{request.CanvasRect}'");
|
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(
|
logger.ZLogDebug(
|
||||||
$"rect: {request.CanvasRect}, minRow: {minRow}, maxRow: {maxRow}, minCol: {minCol}, maxCol: {maxCol}");
|
$"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;
|
bool canBeCached = ( predictedW * predictedH ) <= MAX_CACHED_TILE_SIZE;
|
||||||
if( canBeCached )
|
if( canBeCached )
|
||||||
{
|
{
|
||||||
Span<byte> buffer = stackalloc byte[36];
|
Span<byte> buffer = stackalloc byte[24];
|
||||||
MemoryMarshal.Write(buffer, in minRow);
|
byte minRowByte = (byte)minRow;
|
||||||
MemoryMarshal.Write(buffer[4..], in maxRow);
|
byte maxRowByte = (byte)maxRow;
|
||||||
MemoryMarshal.Write(buffer[8..], in minCol);
|
byte minColByte = (byte)minCol;
|
||||||
MemoryMarshal.Write(buffer[12..], in maxCol);
|
byte maxColByte = (byte)maxCol;
|
||||||
MemoryMarshal.Write(buffer[16..], in cropOffsetX);
|
MemoryMarshal.Write(buffer, in minRowByte);
|
||||||
MemoryMarshal.Write(buffer[20..], in cropOffsetY);
|
MemoryMarshal.Write(buffer[1..], in maxRowByte);
|
||||||
MemoryMarshal.Write(buffer[24..], in cropSizeW);
|
MemoryMarshal.Write(buffer[2..], in minColByte);
|
||||||
MemoryMarshal.Write(buffer[28..], in cropSizeH);
|
MemoryMarshal.Write(buffer[3..], in maxColByte);
|
||||||
MemoryMarshal.Write(buffer[32..], in outputScale);
|
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();
|
cacheKey = Convert.ToHexString(buffer).ToLowerInvariant();
|
||||||
if( cache.TryGetValue(cacheKey, out cacheFile) && File.Exists(cacheFile) )
|
if( cache.TryGetValue(cacheKey, out cacheFile) && File.Exists(cacheFile) )
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue