internal CanvasRenderingContextHolographicSpace(Window window, IHTMLCanvasElement canvas) { this.window = window; this.canvas = canvas; context = CreateEglContext(window.holographicSpace, window.stationaryReferenceFrame); deviceContext.MakeCurrent(context); }
/// <summary> /// Set this GraphicsContext current/uncurrent on device different from the one specified at construction time. /// </summary> /// <param name="deviceContext"> /// A <see cref="IDeviceContext"/> that specify the device context involved. /// </param> /// <param name="flag"> /// A <see cref="Boolean"/> that specify the currency of this GraphicsContext on the /// device context <paramref name="rDevice"/>. /// </param> /// <exception cref="ArgumentException"> /// Exception throw in the case <paramref name="rDevice"/> is <see cref="IntPtr.Zero"/>. /// </exception> /// <exception cref="ObjectDisposedException"> /// Exception throw if this GraphicsContext has been disposed. Once the GraphicsContext has been disposed it cannot be current again. /// </exception> /// <exception cref="InvalidOperationException"> /// Exception throw if this GraphicsContext cannot be made current/uncurrent on the device context specified by <paramref name="rDevice"/>. /// </exception> public void MakeCurrent(IDeviceContext deviceContext, bool flag) { if (deviceContext == null) throw new ArgumentNullException("deviceContext"); if (_DeviceContext == null) throw new ObjectDisposedException("no context associated with this GraphicsContext"); int threadId = System.Threading.Thread.CurrentThread.ManagedThreadId; if (flag) { // Make this context current on device if (deviceContext.MakeCurrent(_RenderContext) == false) throw new InvalidOperationException("context cannot be current because error " + Marshal.GetLastWin32Error()); // Cache current device context _CurrentDeviceContext = deviceContext; // Set current context on this thread (only on success) lock (_RenderThreadsLock) { _RenderThreads[threadId] = this; } switch (Environment.OSVersion.Platform) { case PlatformID.Unix: using (Glx.XLock xLock = new Glx.XLock(((XServerDeviceContext)deviceContext).Display)) { Gl.SyncDelegates(); } break; default: Gl.SyncDelegates(); break; } } else { // Make this context uncurrent on device bool res = deviceContext.MakeCurrent(IntPtr.Zero); // Reset current context on this thread (even on error) lock (_RenderThreadsLock) { _RenderThreads[threadId] = null; } if (res == false) throw new InvalidOperationException("context cannot be uncurrent because error " + Marshal.GetLastWin32Error()); } }