GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) : m_context(context) , m_hostWindow(hostWindow) , m_evasGL(0) , m_evasGLContext(0) , m_evasGLSurface(0) , m_glContext(0) , m_glSurface(0) , m_api(0) , m_renderStyle(renderStyle) { if (renderStyle == GraphicsContext3D::RenderToCurrentGLContext) return; if (m_hostWindow && m_hostWindow->platformPageClient()) { // FIXME: Implement this code path for WebKit1. // Get Evas object from platformPageClient and set EvasGL related members. return; } // For WebKit2, we need to create a dummy ecoreEvas object for the WebProcess in order to use EvasGL APIs. #ifdef HAVE_ECORE_X ecore_evas_init(); m_ecoreEvas = adoptPtr(ecore_evas_gl_x11_new(0, 0, 0, 0, 1, 1)); if (!m_ecoreEvas) return; #else return; #endif Evas* evas = ecore_evas_get(m_ecoreEvas.get()); if (!evas) return; // Create a new Evas_GL object for gl rendering on efl. m_evasGL = evas_gl_new(evas); if (!m_evasGL) return; // Get the API for rendering using OpenGL. // This returns a structure that contains all the OpenGL functions we can use to render in Evas m_api = evas_gl_api_get(m_evasGL); if (!m_api) return; // Create a context m_evasGLContext = evas_gl_context_create(m_evasGL, 0); if (!m_evasGLContext) return; // Create a surface if (!createSurface(0, renderStyle == GraphicsContext3D::RenderDirectlyToHostWindow)) return; makeContextCurrent(); }
bool GraphicsContext3DPrivate::initialize(GraphicsContext3D::Attributes attributes, HostWindow* hostWindow, bool renderDirectlyToHostWindow) { PageClientEfl* pageClient = static_cast<PageClientEfl*>(hostWindow->platformPageClient()); Evas* evas = evas_object_evas_get(pageClient->view()); // Create a new Evas_GL object for gl rendering on efl. m_evasGL = evas_gl_new(evas); if (!m_evasGL) return false; // Get the API for rendering using OpenGL. // This returns a structure that contains all the OpenGL functions we can use to render in Evas m_api = evas_gl_api_get(m_evasGL); if (!m_api) return false; Evas_GL_Context* shareContext = 0; #if USE(ACCELERATED_COMPOSITING) // GC3D with RenderOffscreen style for WebGL has to be shared with AC's context when AC is enabled. if (!renderDirectlyToHostWindow) { GraphicsContext3D* context = pageClient->acceleratedCompositingContext(); if (context) shareContext = static_cast<Evas_GL_Context*>(context->platformGraphicsContext3D()); } #endif // Create a context m_context = evas_gl_context_create(m_evasGL, shareContext); if (!m_context) return false; // Create a surface if (!createSurface(pageClient, renderDirectlyToHostWindow)) return false; return makeContextCurrent(); }