OSDN Git Service

[hwc2] Add surfaceInterface/goldfishHwc2
[android-x86/device-generic-goldfish-opengl.git] / system / surfaceInterface / surfaceInterface.cpp
1 #include "surfaceInterface.h"
2
3 #include <cutils/log.h>
4 #include <gui/Surface.h>
5
6 class SurfaceInterface : public android::ANativeObjectBase<
7                                     ANativeWindow,
8                                     android::Surface,
9                                     android::RefBase> {
10 public:
11     static SurfaceInterface* get();
12     void setAsyncMode(ANativeWindow* anw, bool async) {
13         ALOGD("SurfaceInterface::%s: set async mode %d", __func__, async);
14         window = anw;
15         android::Surface* s = android::Surface::getSelf(window);
16         s->setAsyncMode(async);
17         window = NULL;
18     }
19     ANativeWindow* window;
20 };
21
22 static SurfaceInterface* sSurfaceInterface = NULL;
23
24 SurfaceInterface* SurfaceInterface::get() {
25     if (!sSurfaceInterface)
26         sSurfaceInterface = new SurfaceInterface;
27     return sSurfaceInterface;
28 }
29
30 extern "C" void surfaceInterface_init() {
31     SurfaceInterface::get();
32 }
33
34 extern "C" void surfaceInterface_setAsyncModeForWindow(void* window) {
35     SurfaceInterface::get()->setAsyncMode((ANativeWindow*)window, true);
36 }