summaryrefslogtreecommitdiff
path: root/libkmstest
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2016-03-24 17:05:23 +0200
committerTomi Valkeinen <tomi.valkeinen@ti.com>2016-03-24 17:05:23 +0200
commitd1b34f77d1145b2237d6c22ca7e1c5eca3eb0631 (patch)
tree36ab0604c8221e096d62c4afd9deffa3d885a2a3 /libkmstest
parentc1b856ec21d07545b14395eb93c5ff0cdf93b90d (diff)
Add ExtCPUFramebuffer
Diffstat (limited to 'libkmstest')
-rw-r--r--libkmstest/extcpuframebuffer.cpp50
-rw-r--r--libkmstest/extcpuframebuffer.h42
2 files changed, 92 insertions, 0 deletions
diff --git a/libkmstest/extcpuframebuffer.cpp b/libkmstest/extcpuframebuffer.cpp
new file mode 100644
index 0000000..145168f
--- /dev/null
+++ b/libkmstest/extcpuframebuffer.cpp
@@ -0,0 +1,50 @@
+
+#include "extcpuframebuffer.h"
+#include "test.h"
+
+using namespace std;
+
+namespace kms
+{
+
+ExtCPUFramebuffer::ExtCPUFramebuffer(uint32_t width, uint32_t height, PixelFormat format,
+ uint8_t* buffer, uint32_t pitch)
+ : m_width(width), m_height(height), m_format(format)
+{
+ const PixelFormatInfo& format_info = get_pixel_format_info(m_format);
+
+ m_num_planes = format_info.num_planes;
+
+ ASSERT(m_num_planes == 1);
+
+ const PixelFormatPlaneInfo& pi = format_info.planes[0];
+ FramebufferPlane& plane = m_planes[0];
+
+ plane.stride = pitch;
+ plane.size = plane.stride * height / pi.ysub;
+ plane.map = buffer;
+}
+
+ExtCPUFramebuffer::ExtCPUFramebuffer(uint32_t width, uint32_t height, PixelFormat format,
+ uint8_t* buffers[4], uint32_t pitches[4])
+ : m_width(width), m_height(height), m_format(format)
+{
+ const PixelFormatInfo& format_info = get_pixel_format_info(m_format);
+
+ m_num_planes = format_info.num_planes;
+
+ for (unsigned i = 0; i < format_info.num_planes; ++i) {
+ const PixelFormatPlaneInfo& pi = format_info.planes[i];
+ FramebufferPlane& plane = m_planes[i];
+
+ plane.stride = pitches[i];
+ plane.size = plane.stride * height / pi.ysub;
+ plane.map = buffers[i];
+ }
+}
+
+ExtCPUFramebuffer::~ExtCPUFramebuffer()
+{
+}
+
+}
diff --git a/libkmstest/extcpuframebuffer.h b/libkmstest/extcpuframebuffer.h
new file mode 100644
index 0000000..172841f
--- /dev/null
+++ b/libkmstest/extcpuframebuffer.h
@@ -0,0 +1,42 @@
+#pragma once
+
+#include "kms++.h"
+
+namespace kms
+{
+
+class ExtCPUFramebuffer : public IMappedFramebuffer
+{
+public:
+ ExtCPUFramebuffer(uint32_t width, uint32_t height, PixelFormat format,
+ uint8_t* buffer, uint32_t pitch);
+ ExtCPUFramebuffer(uint32_t width, uint32_t height, PixelFormat format,
+ uint8_t* buffers[4], uint32_t pitches[4]);
+ virtual ~ExtCPUFramebuffer();
+
+ uint32_t width() const { return m_width; }
+ uint32_t height() const { return m_height; }
+
+ PixelFormat format() const { return m_format; }
+ unsigned num_planes() const { return m_num_planes; }
+
+ uint32_t stride(unsigned plane) const { return m_planes[plane].stride; }
+ uint32_t size(unsigned plane) const { return m_planes[plane].size; }
+ uint32_t offset(unsigned plane) const { return 0; }
+ uint8_t* map(unsigned plane) { return m_planes[plane].map; }
+
+private:
+ struct FramebufferPlane {
+ uint32_t size;
+ uint32_t stride;
+ uint8_t *map;
+ };
+
+ uint32_t m_width;
+ uint32_t m_height;
+ PixelFormat m_format;
+
+ unsigned m_num_planes;
+ struct FramebufferPlane m_planes[4];
+};
+}