| /* |
| * Copyright 2016 Google Inc. |
| * |
| * See file CREDITS for list of people who contributed to this |
| * project. |
| * |
| * This program is free software; you can redistribute it and/or |
| * modify it under the terms of the GNU General Public License as |
| * published by the Free Software Foundation; either version 2 of |
| * the License, or (at your option) any later version. |
| * |
| * This program is distributed in the hope that it will be useful, |
| * but without any warranty; without even the implied warranty of |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| * GNU General Public License for more details. |
| * |
| * You should have received a copy of the GNU General Public License |
| * along with this program; if not, write to the Free Software |
| * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| * MA 02111-1307 USA |
| */ |
| |
| #ifndef __DRIVERS_FRAMEBUFFER_FRAMEBUFFER_H__ |
| #define __DRIVERS_FRAMEBUFFER_FRAMEBUFFER_H__ |
| |
| #include <stdint.h> |
| |
| #include "base/graphics/graphics.h" |
| |
| typedef struct { |
| uint32_t version; |
| } FrameBufferHeader; |
| |
| static const uint32_t FrameBufferCurrentVersion = 1; |
| |
| typedef struct FrameBuffer { |
| FrameBufferHeader header; |
| |
| void *buffer; |
| |
| struct { |
| uint32_t x; |
| uint32_t y; |
| } resolution; |
| |
| uint32_t bytes_per_line; |
| uint8_t bits_per_pixel; |
| |
| struct { |
| uint8_t pos; |
| uint8_t size; |
| } red, green, blue, reserved; |
| } FrameBuffer; |
| |
| typedef struct FrameBufferOps { |
| int (*prepare)(struct FrameBufferOps *me, FrameBuffer *buf); |
| } FrameBufferOps; |
| |
| static inline int framebuffer_prepare(FrameBufferOps *me, FrameBuffer *buf) |
| { |
| return me->prepare(me, buf); |
| } |
| |
| static inline uint32_t framebuffer_pixel_value(FrameBuffer *buf, |
| const DcColor *color) |
| { |
| return ((color->red >> (8 - buf->red.size)) << buf->red.pos) | |
| ((color->green >> (8 - buf->green.size)) << buf->green.pos) | |
| ((color->blue >> (8 - buf->blue.size)) << buf->blue.pos); |
| } |
| |
| int framebuffer_read_from_fwdb(FrameBuffer *buf); |
| int framebuffer_write_to_fwdb(FrameBuffer *buf); |
| |
| #endif /* __DRIVERS_FRAMEBUFFER_FRAMEBUFFER_H__ */ |