#pragma once #include "image_renderer.h" #include "include/internal/cef_types_wrappers.h" #include #include #include // Direct framebuffer renderer: blits the full-page CEF bitmap 1:1 onto // /dev/fb0. Requires the terminal to run directly on the Linux framebuffer // console (no X, no yaft/fbterm needed). The page bitmap (BGRA8888) matches // the XRGB8888 framebuffer layout byte-for-byte (B,G,R,ignored), so rows are // copied verbatim. class FbRenderer : public ImageRenderer { public: // offset_x/offset_y: top-left corner of the view (pane) within /dev/fb0. // Zero outside tmux, where the view fills the whole framebuffer. FbRenderer(int width, int height, int cell_width, int cell_height, int offset_x, int offset_y); ~FbRenderer(); void render(const void *buffer, int width, int height, bool hasAlpha, const std::vector &dirtyRects = {}) override; void clear() override; void setTiledRenderingEnabled(bool enabled) override { tiled_rendering_enabled_ = enabled; } void forceFullRender() override { force_full_render_ = true; } void resetFrameCache() override {} static std::mutex &getTerminalMutex(); // True when the VT this renderer draws onto is the currently active VT. // /dev/fb0 mmap writes always hit whatever VT is displayed right now, so // blitting from an inactive VT corrupts the screen the user is looking at. static bool vtIsActive(); private: void blit(const unsigned char *src, int src_w, int src_h, int dx, int dy, int w, int h); int width_; int height_; int cell_width_; int cell_height_; int offset_x_; int offset_y_; int fb_fd_ = -1; uint8_t *fb_map_ = nullptr; size_t fb_len_ = 0; long fb_line_length_ = 0; int fb_bpp_ = 32; int fb_red_offset_ = 16; int fb_green_offset_ = 8; int fb_blue_offset_ = 0; bool direct_copy_ = false; bool tiled_rendering_enabled_; bool force_full_render_; };