Code cleanup.
authorAli Juma <ajuma@mozilla.com>
Thu, 09 Feb 2012 17:39:04 -0500
changeset 89109 58842c4ff57f274a2200f0df062b9dfe04272efd
parent 89108 23107130ea2279672b2fc923e62700fa9b141ae7
child 89110 0cb6641ab21a7bc42229d279334c09376e5defc5
push id22242
push userkgupta@mozilla.com
push dateWed, 14 Mar 2012 15:19:09 +0000
treeherdermozilla-central@936ef50fa498 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Code cleanup.
gfx/gl/GLContextProviderEGL.cpp
gfx/layers/ipc/CompositorParent.cpp
gfx/layers/ipc/CompositorParent.h
mobile/android/base/gfx/GLController.java
--- a/gfx/gl/GLContextProviderEGL.cpp
+++ b/gfx/gl/GLContextProviderEGL.cpp
@@ -1994,17 +1994,17 @@ GLContextProviderEGL::CreateForWindow(ns
         return nsnull;
     }
 
     if (!CreateConfig(&config)) {
         printf_stderr("Failed to create EGL config!\n");
         return nsnull;
     }
 
-#ifdef MOZ_WIDGET_ANDROID
+#ifdef MOZ_JAVA_COMPOSITOR
     printf_stderr("... registering OGL compositor with bridge\n");
     mozilla::AndroidBridge::Bridge()->RegisterCompositor();
 #endif
 
    EGLSurface surface = CreateSurfaceForWindow(aWidget, config);
 
     if (!surface) {
         return nsnull;
--- a/gfx/layers/ipc/CompositorParent.cpp
+++ b/gfx/layers/ipc/CompositorParent.cpp
@@ -141,27 +141,16 @@ CompositorParent::ScheduleComposition()
 
   printf_stderr("Schedule composition\n");
   mCurrentCompositeTask = NewRunnableMethod(this, &CompositorParent::Composite);
   if (!initialComposition && delta.ToMilliseconds() < 15) {
     MessageLoop::current()->PostDelayedTask(FROM_HERE, mCurrentCompositeTask, 15 - delta.ToMilliseconds());
   } else {
     MessageLoop::current()->PostTask(FROM_HERE, mCurrentCompositeTask);
   }
-
-// Test code for async scrolling.
-#ifdef OMTC_TEST_ASYNC_SCROLLING
-  static bool scrollScheduled = false;
-  if (!scrollScheduled) {
-    CancelableTask *composeTask2 = NewRunnableMethod(this,
-                                                     &CompositorParent::TestScroll);
-    MessageLoop::current()->PostDelayedTask(FROM_HERE, composeTask2, 500);
-    scrollScheduled = true;
-  }
-#endif
 }
 
 void
 CompositorParent::SetTransformation(float aScale, nsIntPoint aScrollOffset)
 {
   mXScale = aScale;
   mYScale = aScale;
   mScrollOffset = aScrollOffset;
@@ -382,46 +371,16 @@ CompositorParent::ShadowLayersUpdated()
   if (shadowParents.Length()) {
     Layer* root = static_cast<ShadowLayersParent*>(shadowParents[0])->GetRoot();
     mLayerManager->SetRoot(root);
     SetShadowProperties(root);
   }
   ScheduleComposition();
 }
 
-// Test code for async scrolling.
-#ifdef OMTC_TEST_ASYNC_SCROLLING
-void
-CompositorParent::TestScroll()
-{
-  static int scrollFactor = 0;
-  static bool fakeScrollDownwards = true;
-  if (fakeScrollDownwards) {
-    scrollFactor++;
-    if (scrollFactor > 10) {
-      scrollFactor = 10;
-      fakeScrollDownwards = false;
-    }
-  } else {
-    scrollFactor--;
-    if (scrollFactor < 0) {
-      scrollFactor = 0;
-      fakeScrollDownwards = true;
-    }
-  }
-  SetTransformation(1.0+2.0*scrollFactor/10, nsIntPoint(-25*scrollFactor,
-      -25*scrollFactor));
-  printf_stderr("AsyncRender scroll factor:%d\n", scrollFactor);
-  AsyncRender();
-
-  CancelableTask *composeTask = NewRunnableMethod(this, &CompositorParent::TestScroll);
-  MessageLoop::current()->PostDelayedTask(FROM_HERE, composeTask, 1000/65);
-}
-#endif
-
 PLayersParent*
 CompositorParent::AllocPLayers(const LayersBackend &backendType)
 {
   if (backendType == LayerManager::LAYERS_OPENGL) {
     nsRefPtr<LayerManagerOGL> layerManager = new LayerManagerOGL(mWidget);
     mWidget = NULL;
     mLayerManager = layerManager;
 
--- a/gfx/layers/ipc/CompositorParent.h
+++ b/gfx/layers/ipc/CompositorParent.h
@@ -85,34 +85,32 @@ public:
 
   virtual void ShadowLayersUpdated() MOZ_OVERRIDE;
   void Destroy();
 
   LayerManager* GetLayerManager() { return mLayerManager; }
 
   void SetTransformation(float aScale, nsIntPoint aScrollOffset);
   void AsyncRender();
+
   // Can be called from any thread
   void ScheduleRenderOnCompositorThread(::base::Thread &aCompositorThread);
+  void SchedulePauseOnCompositorThread(::base::Thread &aCompositorThread);
+  void ScheduleResumeOnCompositorThread(::base::Thread &aCompositorThread);
 
   void PauseComposition();
   void ResumeComposition();
-  void SchedulePauseOnCompositorThread(::base::Thread &aCompositorThread);
-  void ScheduleResumeOnCompositorThread(::base::Thread &aCompositorThread);
 
 protected:
   virtual PLayersParent* AllocPLayers(const LayersBackend &backendType);
   virtual bool DeallocPLayers(PLayersParent* aLayers);
 
 private:
   void ScheduleComposition();
   void Composite();
-#ifdef OMTC_TEST_ASYNC_SCROLLING
-  void TestScroll();
-#endif
   void TransformShadowTree(Layer* aLayer, const ViewTransform& aTransform,
                            float aTempScaleDiffX = 1.0,
                            float aTempScaleDiffY = 1.0);
 
   // Platform specific functions
 #ifdef MOZ_WIDGET_ANDROID
   /**
    * Asks Java for the viewport position and updates the world transform
--- a/mobile/android/base/gfx/GLController.java
+++ b/mobile/android/base/gfx/GLController.java
@@ -175,30 +175,34 @@ public class GLController {
         notifyAll();
     }
 
     synchronized void sizeChanged(int newWidth, int newHeight) {
         mWidth = newWidth;
         mHeight = newHeight;
     }
 
-    private void initEGLContext() {
+    private void initEGL() {
         mEGL = (EGL10)EGLContext.getEGL();
 
         mEGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
         if (mEGLDisplay == EGL10.EGL_NO_DISPLAY) {
             throw new GLControllerException("eglGetDisplay() failed");
         }
 
         int[] version = new int[2];
         if (!mEGL.eglInitialize(mEGLDisplay, version)) {
             throw new GLControllerException("eglInitialize() failed");
         }
 
         mEGLConfig = chooseConfig();
+    }
+
+    private void initEGLContext() {
+        initEGL();
 
         int[] attribList = { EGL_CONTEXT_CLIENT_VERSION, mGLVersion, EGL10.EGL_NONE };
         mEGLContext = mEGL.eglCreateContext(mEGLDisplay, mEGLConfig, EGL10.EGL_NO_CONTEXT,
                                             attribList);
         if (mEGLContext == null || mEGLContext == EGL10.EGL_NO_CONTEXT) {
             throw new GLControllerException("createContext() failed");
         }
     }
@@ -243,32 +247,21 @@ public class GLController {
 
         mGL = mEGLContext.getGL();
 
         if (mView.getRenderer() != null) {
             mView.getRenderer().onSurfaceCreated((GL10)mGL, mEGLConfig);
             mView.getRenderer().onSurfaceChanged((GL10)mGL, mView.getWidth(), mView.getHeight());
         }
     }
-        
+
+    // Provides an EGLSurface without assuming ownership of this surface.
     private EGLSurface provideEGLSurface() {
         if (mEGL == null) {
-            mEGL = (EGL10)EGLContext.getEGL();
-
-            mEGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
-            if (mEGLDisplay == EGL10.EGL_NO_DISPLAY) {
-                throw new GLControllerException("eglGetDisplay() failed");
-            }
-
-            int[] version = new int[2];
-            if (!mEGL.eglInitialize(mEGLDisplay, version)) {
-                throw new GLControllerException("eglInitialize() failed");
-            }
-
-            mEGLConfig = chooseConfig();
+            initEGL();
         }
 
         SurfaceHolder surfaceHolder = mView.getHolder();
         mEGLSurface = mEGL.eglCreateWindowSurface(mEGLDisplay, mEGLConfig, surfaceHolder, null);
         if (mEGLSurface == null || mEGLSurface == EGL10.EGL_NO_SURFACE) {
             throw new GLControllerException("EGL window surface could not be created!");
         }