blob: be813dccbd88821dd064275250dbc9c86865d2d8 [file] [log] [blame]
Tao Bao557fa1f2017-02-07 12:51:00 -08001/*
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 Bao92bdb5a2018-10-21 12:12:37 -070017#pragma once
Tao Bao557fa1f2017-02-07 12:51:00 -080018
19#include <linux/fb.h>
Tao Bao92bdb5a2018-10-21 12:12:37 -070020#include <stdint.h>
Tao Bao557fa1f2017-02-07 12:51:00 -080021
22#include "graphics.h"
23#include "minui/minui.h"
24
Tao Bao92bdb5a2018-10-21 12:12:37 -070025class 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 Bao557fa1f2017-02-07 12:51:00 -080038class 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 Bao92bdb5a2018-10-21 12:12:37 -070049 GRSurfaceFbdev gr_framebuffer[2];
Tao Bao557fa1f2017-02-07 12:51:00 -080050 bool double_buffered;
Tao Bao92bdb5a2018-10-21 12:12:37 -070051 GRSurfaceFbdev* gr_draw;
Tao Bao557fa1f2017-02-07 12:51:00 -080052 int displayed_buffer;
53 fb_var_screeninfo vi;
54 int fb_fd;
55};