Closed Bug 573181 Opened 10 years ago Closed 9 years ago

enable GL layers on Android

Categories

(Core :: Widget: Android, defect)

All
Android
defect
Not set

Tracking

()

RESOLVED FIXED

People

(Reporter: vlad, Assigned: vlad)

Details

Attachments

(1 file)

This gets things building and semi-working (though it requires the accelerated attrib, or forcing acceleration in nsWindow.cpp).  Some grossness required to call eglCreateWindowSurface.  Handles rotation etc. fine, because conveniently, for a window surface, EGL will resize the surface for us.  However, it doesn't handle -losing- the surface, such as what happens when the app is suspended and is resumed.  We can fix that in a followup.
Attachment #452395 - Flags: review?(mwu)
Comment on attachment 452395 [details] [diff] [review]
android gl layers, widget patch


>+mozilla::layers::LayerManager*
>+nsWindow::GetLayerManager()
>+{
>+    nsWindow *topWindow = TopWindow();
>+
>+    if (!topWindow)
>+        return nsBaseWidget::GetLayerManager();
>+
>+    if (GetAcceleratedRendering() != mUseAcceleratedRendering) {
>+        mLayerManager = NULL;
>+        mUseAcceleratedRendering = GetAcceleratedRendering();
>+    }
>+
>+    if (mLayerManager ||
>+        !mUseAcceleratedRendering ||
>+        sFailedToCreateGLContext)
>+    {
>+        return nsBaseWidget::GetLayerManager();
>+    }
>+
>+    if (!sGLContext) {
>+        // the window we give doesn't matter here
>+        sGLContext = mozilla::gl::sGLContextProvider.CreateForWindow(this);
>+    }
>+
>+    if (sGLContext) {
>+        nsRefPtr<mozilla::layers::LayerManagerOGL> layerManager =
>+            new mozilla::layers::LayerManagerOGL(this);
>+
>+        if (layerManager && layerManager->Initialize(sGLContext))
>+            mLayerManager = layerManager;
>+    }
>+
>+    if (!sGLContext || !mLayerManager) {
>+        sGLContext = nsnull;
>+        sFailedToCreateGLContext = PR_TRUE;
>+    }
>+
>+    return nsBaseWidget::GetLayerManager();
>+}
>+
Hm, is all of this necessary? The default impl in nsBaseWidget seems to do largely the same thing.

Also, can you ensure that this patch works on stock mobile-browser without acceleration? I get a black screen and a bunch of 

I/Gecko   ( 1710): ### Software drawing, but too small a buffer 1048576 expected 2355200 (or no buffer 0x0)!

with this patch.
Comment on attachment 452395 [details] [diff] [review]
android gl layers, widget patch

>diff -r c0e6c5d8b96d embedding/android/GeckoApp.java
>--- a/embedding/android/GeckoApp.java	Wed Jun 16 13:55:50 2010 -0700
>+++ b/embedding/android/GeckoApp.java	Fri Jun 18 17:16:55 2010 -0700
>@@ -121,7 +121,7 @@
>                        new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
>                                                   ViewGroup.LayoutParams.FILL_PARENT));
> 
>-        useSoftwareDrawing = true; //isInEmulator() == 1;
>+        useSoftwareDrawing = false; //isInEmulator() == 1;
2d path seems ok with this change removed. r+ without this chunk.
Attachment #452395 - Flags: review?(mwu) → review+
http://hg.mozilla.org/mozilla-central/rev/8117a97f1eee
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.