namespace WebCore {
-static bool vendorNeedsMakeCurrent()
-{
- static bool queryDone = false;
- static bool needsMakeCurrent = true;
-
- if (!queryDone) {
- queryDone = true;
- if (EGLHelper::isVendor("imagination") || EGLHelper::isVendor("mesa") || EGLHelper::isVendor("arm"))
- needsMakeCurrent = false;
- }
-
- return needsMakeCurrent;
-}
-
class PixmapContextPool {
protected:
PixmapContextPool(void);
GLPlatformContext* getContext(GLPlatformSurface* surface);
private:
- typedef HashMap<int, OwnPtr<GLPlatformContext> > PixmapContextMap;
+ typedef HashMap<GLPlatformSurface::SurfaceAttributes, OwnPtr<GLPlatformContext> > PixmapContextMap;
PixmapContextMap m_pixmapContexts;
};
GLPlatformContext* PixmapContextPool::getContext(GLPlatformSurface* surface)
{
GLPlatformSurface::SurfaceAttributes attributes = surface->attributes();
- bool hasAlpha = attributes & GLPlatformSurface::SupportAlpha;
- bool hasDepth = attributes & GLPlatformSurface::SupportDepth;
- bool hasStencil = attributes & GLPlatformSurface::SupportStencil;
- bool isLockable = attributes & GLPlatformSurface::Lockable;
- int contextId = ((isLockable) | (hasAlpha << 1) | (hasDepth << 2) | (hasStencil << 3));
- GLPlatformContext* pixmapContext = m_pixmapContexts.get(contextId);
+ GLPlatformContext* pixmapContext = m_pixmapContexts.get(attributes);
if (!pixmapContext) {
OwnPtr<GLPlatformContext> context = GLPlatformContext::createContext(GraphicsContext3D::RenderOffscreen);
if (context && context->initialize(surface)) {
pixmapContext = context.get();
- m_pixmapContexts.add(contextId, context.release());
+ m_pixmapContexts.add(attributes, context.release());
} else
pixmapContext = 0;
}
bool SharedPlatformSurfaceTizen::supportsLockSurfaceExtension()
{
- static bool extSupportQueried = false;
- static bool supportLockSurfaceExt = false;
-
- if (extSupportQueried)
- return supportLockSurfaceExt;
-
- extSupportQueried = true;
- EGLDisplay display = EGLHelper::currentDisplay();
-
- if (display == EGL_NO_DISPLAY)
- return false;
-
- supportLockSurfaceExt = GLPlatformContext::supportsEGLExtension(display, "EGL_KHR_lock_surface");
+ static bool supportLockSurfaceExt = GLPlatformContext::supportsEGLExtension(EGLHelper::currentDisplay(), "EGL_KHR_lock_surface");
return supportLockSurfaceExt;
}
SharedPlatformSurfaceTizen::~SharedPlatformSurfaceTizen()
{
- if (m_offScreenSurface) {
- m_offScreenContext->releaseCurrent();
+ if (!m_offScreenSurface)
+ return;
+
+ GLPlatformContext* previousContext = GLPlatformContext::getCurrent();
+ GLPlatformSurface* previousSurface = GLPlatformSurface::getCurrent();
+ if (previousSurface == m_offScreenSurface.get())
+ previousSurface = 0;
+
+ if (makeContextCurrent()) {
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ glBindTexture(GL_TEXTURE_2D, 0);
m_offScreenSurface->destroy();
+ if (!previousContext || !previousSurface) {
+ m_offScreenContext->releaseCurrent();
+ return;
+ }
}
+
+ if (previousContext && previousSurface)
+ previousContext->makeCurrent(previousSurface);
}
bool SharedPlatformSurfaceTizen::initialize(GLPlatformSurface::SurfaceAttributes attributes)
bool SharedPlatformSurfaceTizen::lockSurface()
{
- if (vendorNeedsMakeCurrent())
+ static bool needsMakeCurrent = !(EGLHelper::isVendor("imagination") || EGLHelper::isVendor("mesa") || EGLHelper::isVendor("arm"));
+ if (needsMakeCurrent)
makeContextCurrent();
return m_offScreenSurface->lockSurface();