Implement drawImage() in PLS Rather than implementing a specific handler for this method, we add PaintType::image to PLS and implement drawImage() as drawPath() with a rectangle path and an image paint. Diffs= adeebb26a Implement drawImage() in PLS (#5780) Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
diff --git a/.rive_head b/.rive_head index f69ef3f..0d382b8 100644 --- a/.rive_head +++ b/.rive_head
@@ -1 +1 @@ -8caa7d377f368af8c667ca209a2ce7aef8679be2 +adeebb26a7ac58a1aaa18a40ed9d98af46735c97
diff --git a/decoders/build/premake5.lua b/decoders/build/premake5.lua index c1552b9..5c139d0 100644 --- a/decoders/build/premake5.lua +++ b/decoders/build/premake5.lua
@@ -20,6 +20,7 @@ includedirs { '../include', + '../../include', libpng, }
diff --git a/decoders/src/bitmap_decoder.cpp b/decoders/src/bitmap_decoder.cpp index d60e8e3..8d4c04e 100644 --- a/decoders/src/bitmap_decoder.cpp +++ b/decoders/src/bitmap_decoder.cpp
@@ -3,6 +3,9 @@ */ #include "rive/decoders/bitmap_decoder.hpp" +#include "rive/rive_types.hpp" +#include <stdio.h> +#include <string.h> #include <vector> Bitmap::Bitmap(uint32_t width, @@ -27,6 +30,7 @@ case PixelFormat::RGBA: return 4; } + RIVE_UNREACHABLE(); } size_t Bitmap::byteSize(PixelFormat format) const @@ -81,7 +85,7 @@ // If the fingerprint doesn't match, discrd this decoder. These are all bytes so .size() is // fine here. - if (std::memcmp(fingerprint.data(), bytes, fingerprint.size()) != 0) + if (memcmp(fingerprint.data(), bytes, fingerprint.size()) != 0) { continue; } @@ -105,13 +109,13 @@ auto nextByteSize = byteSize(format); auto nextBytes = std::unique_ptr<uint8_t[]>(new uint8_t[nextByteSize]); - auto fromBytesPerPixel = bytesPerPixel(m_PixelFormat); - auto toBytesPerPixel = bytesPerPixel(format); + size_t fromBytesPerPixel = bytesPerPixel(m_PixelFormat); + size_t toBytesPerPixel = bytesPerPixel(format); int writeIndex = 0; int readIndex = 0; - for (int i = 0; i < m_Width * m_Height; i++) + for (uint32_t i = 0; i < m_Width * m_Height; i++) { - for (int j = 0; j < toBytesPerPixel; j++) + for (size_t j = 0; j < toBytesPerPixel; j++) { nextBytes[writeIndex++] = j < fromBytesPerPixel ? m_Bytes[readIndex++] : 255; }
diff --git a/decoders/src/decode_png.cpp b/decoders/src/decode_png.cpp index a9a0e64..157dfa2 100644 --- a/decoders/src/decode_png.cpp +++ b/decoders/src/decode_png.cpp
@@ -4,8 +4,9 @@ #include "rive/decoders/bitmap_decoder.hpp" #include "png.h" -#include <cassert> #include <algorithm> +#include <cassert> +#include <string.h> struct EncodedImageBuffer { @@ -56,11 +57,7 @@ return nullptr; } - EncodedImageBuffer stream = { - .bytes = bytes, - .position = 0, - .size = byteCount, - }; + EncodedImageBuffer stream = {bytes, 0, byteCount}; png_set_read_fn(png_ptr, &stream, ReadDataFromMemory);