From 492d1e617cc8ac392784c3b4daa2bcfc79e4415f Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 1 Sep 2016 11:16:18 +0200 Subject: Don't use stride and use static buffer in example plugin. --- plugintest.cc | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'plugintest.cc') diff --git a/plugintest.cc b/plugintest.cc index a23c44b..cbe34fe 100644 --- a/plugintest.cc +++ b/plugintest.cc @@ -182,25 +182,27 @@ void PluginTest::onInlineRedraw(std::size_t width, std::size_t max_height, InlineDrawContext& context) { - std::size_t height = std::min(width / 2, max_height); + std::size_t height = std::min(width, max_height); + if (!context.data || (context.width != width)) { - delete[] context.data; - context.data = new std::uint8_t[width * height * 4]; + context.width = width; + context.height = height; + context.data = (unsigned char*)inlineDisplayBuffer; } - context.width = width; - context.height = height; + + std::cout << "width: " << width << " height: " << height << std::endl; for(std::size_t x = 0; x < context.width; ++x) { for(std::size_t y = 0; y < context.height; ++y) { - unsigned char* p = context.data + ((x + y * context.width) * 4); - p[0] = 0; // B; - p[1] = 0; // G - p[2] = 255; // R - p[3] = 0; // A + inlineDisplayBuffer[x + y * context.width] = + pgzRGBA(lround(255 * (float(x) / float(context.width))), + lround(255 * (1 + -1 * (float(x) / float(context.width)))), + lround(255 * (float(y) / float(context.height))), + 0); // Apparently not used } } } -- cgit v1.2.3