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(); setAsyncMode(ANativeWindow * anw,bool async)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 get()24SurfaceInterface* SurfaceInterface::get() { 25 if (!sSurfaceInterface) 26 sSurfaceInterface = new SurfaceInterface; 27 return sSurfaceInterface; 28 } 29 surfaceInterface_init()30extern "C" void surfaceInterface_init() { 31 SurfaceInterface::get(); 32 } 33 surfaceInterface_setAsyncModeForWindow(void * window)34extern "C" void surfaceInterface_setAsyncModeForWindow(void* window) { 35 SurfaceInterface::get()->setAsyncMode((ANativeWindow*)window, true); 36 } 37