class_docstr: SDL2 backend for Canvas abstract class.
class_docstr_tok: ["SDL2","backend","for","Canvas","abstract","class","."]
code: def __init__(self, vispy_canvas, **kwargs):
      BaseCanvasBackend.__init__(self, vispy_canvas)
      p = self._process_backend_kwargs(kwargs)
      self._initialized = False
  
      # Deal with config
      _set_config(p.context.config)
      # Deal with context
      p.context.shared.add_ref("sdl2", self)
      if p.context.shared.ref is self:
          share = None
      else:
          other = p.context.shared.ref
          share = other._id.window, other._native_context
          sdl2.SDL_GL_MakeCurrent(*share)
          sdl2.SDL_GL_SetAttribute(
              sdl2.SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1
          )
  
      sdl2.SDL_GL_SetSwapInterval(1 if p.vsync else 0)
      flags = sdl2.SDL_WINDOW_OPENGL
      flags |= sdl2.SDL_WINDOW_SHOWN  # start out shown
      flags |= sdl2.SDL_WINDOW_ALLOW_HIGHDPI
      flags |= sdl2.SDL_WINDOW_RESIZABLE if p.resizable else 0
      flags |= sdl2.SDL_WINDOW_BORDERLESS if not p.decorate else 0
      if p.fullscreen is not False:
          self._fullscreen = True
          if p.fullscreen is not True:
              logger.warning(
                  "Cannot specify monitor number for SDL2 "
                  "fullscreen, using default"
              )
          flags |= sdl2.SDL_WINDOW_FULLSCREEN_DESKTOP
      else:
          self._fullscreen = False
      self._mods = list()
      if p.position is None:
          position = [sdl2.SDL_WINDOWPOS_UNDEFINED] * 2
      else:
          position = None
      self._id = sdl2.ext.Window(p.title, p.size, position, flags)
      if not self._id.window:
          raise RuntimeError("Could not create window")
      if share is None:
          self._native_context = sdl2.SDL_GL_CreateContext(
              self._id.window
          )
      else:
          self._native_context = sdl2.SDL_GL_CreateContext(share[0])
      self._sdl_id = sdl2.SDL_GetWindowID(self._id.window)
      _VP_SDL2_ALL_WINDOWS[self._sdl_id] = self
  
      # Init
      self._initialized = True
      self._needs_draw = False
      self._vispy_canvas.set_current()
      self._vispy_canvas.events.initialize()
      if not p.show:
          self._vispy_set_visible(False)
  
imports: from __future__ import division
  import atexit
  import ctypes
  from time import sleep
  import warnings
  import gc
  from ..base import BaseApplicationBackend, BaseCanvasBackend, BaseTimerBackend
  from ...util import keys, logger
  from ...util.ptime import time
  from ...None import config
label_desc: Use image node_id 1 to create a new CanvasBackend object from inherited base classes: BaseCanvasBackend with example: obj = CanvasBackend(vispy_canvas)