yueying0083 / javachromiumembedded

Automatically exported from code.google.com/p/javachromiumembedded
0 stars 0 forks source link

OSR mode - Fix to avoid blank after window is reparented #56

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Edit MainFrame.java so that the browser widget draws into one JFrame or 
JPanel, then move it to another JFrame or JPanel. The widget now draws blank 
(osr mode).

What is the expected output? What do you see instead?
AWT/Swing destroys peers every time a widget is removed from its hierarchy. 
Browser widget should continue to draw fine after being moved to a different 
container / hierarchy.

What version of the product are you using? On what operating system?
Latest JCEF r31 but this has been a pb from beginning. Both Windows and Mac are 
affected.

Please provide any additional information below.
Workaround in OSR mode is to reinitialize the GL2 context everytime we get 
passed a new one.

CefRenderer.java

  private Rectangle original_popup_rect_ = new Rectangle(0, 0, 0, 0);

+  // GL2 context changes every time window is reparented. New one needs to be 
re-initialized otherwise texture won't draw.
+  GL2 initializedContext;

  protected void initialize(GL2 gl2) {
-    if (initialized_)
+   if (initializedContext == gl2)

-    initialized_ = true;
+    initializedContext = gl2;

  protected void onPaint(GL2 gl2,
                         boolean popup,
                         Rectangle[] dirtyRects,
                         ByteBuffer buffer,
                         int width,
                         int height) {
-    if (!initialized_)
+    if (gl2 != initializedContext) {

Original issue reported on code.google.com by christop...@gmail.com on 14 Mar 2014 at 4:52

GoogleCodeExporter commented 9 years ago
Thanks, fixed in revision 83. It would be easier to integrate your changes if 
you attached them as patch files.

Original comment by magreenb...@gmail.com on 17 Jun 2014 at 5:58