@Override
  public void onPaintWithSharedMem(CefBrowser browser,
                                   boolean popup,
                                   int dirtyRectsCount,
                                   String sharedMemName,
                                   long sharedMemHandle,
                                   int width,
                                   int height) {
    // TODO: support popups
    SharedMemory.WithRaster mem = mySharedMemCache.get(sharedMemName);
    if (mem == null) {
      cleanCacheIfNecessary();
      mem = new SharedMemory.WithRaster(sharedMemName, sharedMemHandle);
      synchronized (this) {
        // Use synchronization to avoid leak (when disposeNativeRes is called just before putting into cache).
        if (myIsDisposed)
          return;
        mySharedMemCache.put(sharedMemName, mem);
      }
    }

    mem.setWidth(width);
    mem.setHeight(height);
    mem.setDirtyRectsCount(dirtyRectsCount);
    mem.lasUsedMs = System.currentTimeMillis();
    myCurrentFrame = mem;

    // TODO: calculate outerRect
    myContentOutdated = true;
    SwingUtilities.invokeLater(() -> {
      if (!browser.getUIComponent().isShowing()) return;
      JRootPane root = SwingUtilities.getRootPane(browser.getUIComponent());
      RepaintManager rm = RepaintManager.currentManager(root);
      Rectangle dirtySrc = new Rectangle(0, 0, browser.getUIComponent().getWidth(), browser.getUIComponent().getHeight());
      Rectangle dirtyDst = SwingUtilities.convertRectangle(browser.getUIComponent(), dirtySrc, root);
      int dx = 1;
      // NOTE: should mark area outside browser (otherwise background component won't be repainted)
      rm.addDirtyRegion(root, dirtyDst.x - dx, dirtyDst.y - dx, dirtyDst.width + dx * 2, dirtyDst.height + dx * 2);
    });
  }
@Override
  public void onPaintWithSharedMem(CefBrowser browser,
                                   boolean popup,
                                   int dirtyRectsCount,
                                   String sharedMemName,
                                   long sharedMemHandle,
                                   int width,
                                   int height)