MCPcopy Create free account
hub / github.com/Bananymous/banan-os / sync_pixels_linear

Method sync_pixels_linear

kernel/kernel/Device/FramebufferDevice.cpp:205–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203 sync_pixels_rectangle(
204 rectangle.min_x,
205 rectangle.min_y,
206 rectangle.max_x - rectangle.min_x,
207 rectangle.max_y - rectangle.min_y
208 );
209 return 0;
210 }
211 }
212
213 return CharacterDevice::ioctl_impl(request, arg);
214 }
215
216 uint32_t FramebufferDevice::get_pixel(uint32_t x, uint32_t y) const
217 {
218 ASSERT(x < m_width && y < m_height);
219 static_assert(BANAN_FB_BPP == 32);
220 return reinterpret_cast<uint32_t*>(m_video_buffer->vaddr())[y * m_width + x];
221 }
222
223 void FramebufferDevice::set_pixel(uint32_t x, uint32_t y, uint32_t rgb)
224 {
225 if (x >= m_width || y >= m_height)
226 return;
227 static_assert(BANAN_FB_BPP == 32);
228 reinterpret_cast<uint32_t*>(m_video_buffer->vaddr())[y * m_width + x] = rgb;
229 }
230
231 void FramebufferDevice::fill(uint32_t rgb)
232 {
233 static_assert(BANAN_FB_BPP == 32);
234 auto* video_buffer_u32 = reinterpret_cast<uint32_t*>(m_video_buffer->vaddr());
235 for (uint32_t i = 0; i < m_width * m_height; i++)
236 video_buffer_u32[i] = rgb;
237 }
238
239 void FramebufferDevice::scroll(int32_t rows, uint32_t rgb)
240 {
241 if (rows == 0)
242 return;
243 rows = BAN::Math::clamp<int32_t>(rows, -m_height, m_height);
244 const uint32_t abs_rows = BAN::Math::abs(rows);
245
246 auto* video_buffer_u8 = reinterpret_cast<uint8_t*>(m_video_buffer->vaddr());
247 uint8_t* src = (rows < 0) ? video_buffer_u8 : &video_buffer_u8[(abs_rows * m_width) * (BANAN_FB_BPP / 8)];
248 uint8_t* dst = (rows > 0) ? video_buffer_u8 : &video_buffer_u8[(abs_rows * m_width) * (BANAN_FB_BPP / 8)];
249 memmove(dst, src, (m_height - abs_rows) * m_width * (BANAN_FB_BPP / 8));
250
251 uint32_t start_y = (rows < 0) ? 0 : m_height - abs_rows;
252 uint32_t stop_y = (rows < 0) ? abs_rows : m_height;
253 for (uint32_t y = start_y; y < stop_y; y++)
254 for (uint32_t x = 0; x < m_width; x++)
255 set_pixel(x, y, rgb);
256 }
257
258 void FramebufferDevice::sync_pixels_full()
259 {

Callers 1

do_msyncMethod · 0.80

Calls 3

memcpyFunction · 0.85
minFunction · 0.50
vaddrMethod · 0.45

Tested by

no test coverage detected