MCPcopy Create free account
hub / github.com/Logicalshift/flo_draw / decode_texture_set_bytes

Method decode_texture_set_bytes

canvas/src/decoding.rs:1483–1505  ·  view source on GitHub ↗

Decodes a texture 'set bytes' operation

(chr: char, texture_id: TextureId, param: String, bytes: DecodeBytes)

Source from the content-addressed store, hash-verified

1481 /// Decodes a texture 'set bytes' operation
1482 ///
1483 fn decode_texture_set_bytes(chr: char, texture_id: TextureId, param: String, bytes: DecodeBytes) -> Result<(DecoderState, Option<Draw>), DecoderError> {
1484 // 4 u32s and some data
1485 if param.len() < 24 {
1486 let mut param = param;
1487 param.push(chr);
1488 return Ok((DecoderState::TextureOpSetBytes(texture_id, param, bytes), None));
1489 }
1490
1491 let bytes = bytes.decode(chr)?;
1492
1493 if !bytes.ready() {
1494 return Ok((DecoderState::TextureOpSetBytes(texture_id, param, bytes), None));
1495 }
1496
1497 // Decode the data
1498 let mut chars = param.chars();
1499 let x = Self::decode_u32(&mut chars)?;
1500 let y = Self::decode_u32(&mut chars)?;
1501 let w = Self::decode_u32(&mut chars)?;
1502 let h = Self::decode_u32(&mut chars)?;
1503
1504 Ok((DecoderState::None, Some(Draw::Texture(texture_id, TextureOp::SetBytes(x, y, w, h, Arc::new(bytes.to_bytes()?))))))
1505 }
1506
1507 ///
1508 /// Decodes a texture 'set fill transparency'

Callers

nothing calls this directly

Calls 4

TextureClass · 0.85
decodeMethod · 0.80
readyMethod · 0.80
to_bytesMethod · 0.80

Tested by

no test coverage detected