80,492
社区成员
发帖
与我相关
我的任务
分享
status_t EglWindow::createWindow(const sp<IGraphicBufferProducer>& surface) {
if (mEglSurface != EGL_NO_SURFACE) {
ALOGE("surface already created");
return UNKNOWN_ERROR;
}
status_t err = eglSetupContext(false);
if (err != NO_ERROR) {
return err;
}
// Cache the current dimensions. We're not expecting these to change.
surface->query(NATIVE_WINDOW_WIDTH, &mWidth);
surface->query(NATIVE_WINDOW_HEIGHT, &mHeight);
ANativeWindow_Buffer outBuffer;
// Output side (EGL surface to draw on).
sp<ANativeWindow> anw = new Surface(surface);
//surface->lock(&outBuffer, NULL);
//ssize_t bpr = outBuffer.stride * bytesPerPixel(outBuffer.format);
//android_memset16((uint16_t*)outBuffer.bits, 0xF800, bpr*outBuffer.height);
//surface->unlockAndPost();
mEglSurface = eglCreateWindowSurface(mEglDisplay, mEglConfig, anw.get(),NULL);
if (mEglSurface == EGL_NO_SURFACE) {
ALOGE("eglCreateWindowSurface error: %#x", eglGetError());
eglRelease();
return UNKNOWN_ERROR;
}
return NO_ERROR;
}