convert framebuffer to class (#19800)

* class FrameBuffer

* fix build error

* remove bootlog
This commit is contained in:
Dean Lee
2021-01-28 21:47:05 +08:00
committed by GitHub
parent 4f995b35d5
commit 6583206ed4
9 changed files with 39 additions and 34 deletions
+11 -8
View File
@@ -1,6 +1,6 @@
#include "framebuffer.h"
#include "util.h"
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <ui/DisplayInfo.h>
@@ -32,7 +32,7 @@ struct FramebufferState {
EGLContext context;
};
void framebuffer_swap(FramebufferState *s) {
void FrameBuffer::swap() {
eglSwapBuffers(s->display, s->surface);
assert(glGetError() == GL_NO_ERROR);
}
@@ -43,17 +43,15 @@ bool set_brightness(int brightness) {
return 0 == write_file("/sys/class/leds/lcd-backlight/brightness", bright, strlen(bright));
}
void framebuffer_set_power(FramebufferState *s, int mode) {
void FrameBuffer::set_power(int mode) {
SurfaceComposerClient::setDisplayPowerMode(s->dtoken, mode);
}
FramebufferState* framebuffer_init(
const char* name, int32_t layer, int alpha,
int *out_w, int *out_h) {
FrameBuffer::FrameBuffer(const char *name, uint32_t layer, int alpha, int *out_w, int *out_h) {
status_t status;
int success;
FramebufferState *s = new FramebufferState;
s = new FramebufferState;
s->session = new SurfaceComposerClient();
assert(s->session != NULL);
@@ -141,6 +139,11 @@ FramebufferState* framebuffer_init(
if (out_w) *out_w = w;
if (out_h) *out_h = h;
}
return s;
FrameBuffer::~FrameBuffer() {
eglDestroyContext(s->display, s->context);
eglDestroySurface(s->display, s->surface);
eglTerminate(s->display);
delete s;
}