/** * Update the texture if the native WebView window has changed. * * @param dc Draw context */ @Override protected void updateIfNeeded(DrawContext dc) { // Return immediately if the native WebViewWindow object isn't initialized, and wait to update // until the // native object is initialized. This method is called after the texture is bound, so we'll // get another // chance to update as long as the WebView generates repaint events when it changes. long webViewWindowPtr = WindowsWebView.this.webViewWindowPtr; if (webViewWindowPtr == 0) return; // Return immediately if the texture isn't in the texture cache, and wait to update until the // texture is // initialized and placed in the cache. This method is called after the texture is bound, so // we'll get // another chance to update as long as the WebView generates repaint events when it changes. Texture texture = this.getTextureFromCache(dc); if (texture == null) return; // Load the WebViewWindow's current display pixels into the currently bound OGL texture if our // update time // is different than the WebViewWindow's update time. long newUpdateTime = WindowsWebViewJNI.getUpdateTime(webViewWindowPtr); if (newUpdateTime != this.updateTime) { WindowsWebViewJNI.loadDisplayInGLTexture(webViewWindowPtr, texture.getTarget()); this.updateTime = newUpdateTime; } }