Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Tao Bao | 92bdb5a | 2018-10-21 12:12:37 -0700 | [diff] [blame] | 17 | #pragma once |
Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 18 | |
| 19 | #include <linux/fb.h> |
Tao Bao | 92bdb5a | 2018-10-21 12:12:37 -0700 | [diff] [blame] | 20 | #include <stdint.h> |
Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 21 | |
| 22 | #include "graphics.h" |
| 23 | #include "minui/minui.h" |
| 24 | |
Tao Bao | 92bdb5a | 2018-10-21 12:12:37 -0700 | [diff] [blame] | 25 | class GRSurfaceFbdev : public GRSurface { |
| 26 | public: |
| 27 | uint8_t* data() override { |
| 28 | return buffer_; |
| 29 | } |
| 30 | |
| 31 | private: |
| 32 | friend class MinuiBackendFbdev; |
| 33 | |
| 34 | // Points to the start of the buffer: either the mmap'd framebuffer or one allocated in-memory. |
| 35 | uint8_t* buffer_; |
| 36 | }; |
| 37 | |
Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 38 | class MinuiBackendFbdev : public MinuiBackend { |
| 39 | public: |
| 40 | GRSurface* Init() override; |
| 41 | GRSurface* Flip() override; |
| 42 | void Blank(bool) override; |
| 43 | ~MinuiBackendFbdev() override; |
| 44 | MinuiBackendFbdev(); |
| 45 | |
| 46 | private: |
| 47 | void SetDisplayedFramebuffer(unsigned n); |
| 48 | |
Tao Bao | 92bdb5a | 2018-10-21 12:12:37 -0700 | [diff] [blame] | 49 | GRSurfaceFbdev gr_framebuffer[2]; |
Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 50 | bool double_buffered; |
Tao Bao | 92bdb5a | 2018-10-21 12:12:37 -0700 | [diff] [blame] | 51 | GRSurfaceFbdev* gr_draw; |
Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 52 | int displayed_buffer; |
| 53 | fb_var_screeninfo vi; |
| 54 | int fb_fd; |
| 55 | }; |