Clean up some hacks and useless code
authorBenoit Girard <b56girard@gmail.com>
Thu, 15 Dec 2011 16:31:16 -0500
changeset 92328 df720caee3c59c528aee6e3cd6017836c5c07cd1
parent 92327 17e4dbb62bbeed7a7d54b38f2ecbd95b51d87fdc
child 92329 52654c3e0493b2cea29db01118a5c4d54fa1fb90
child 92330 154e2da9922581f16fac82e3c7375802912900d2
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone11.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
Clean up some hacks and useless code
gfx/gl/GLContextProviderCGL.mm
gfx/layers/basic/BasicLayers.cpp
gfx/layers/ipc/CompositorChild.cpp
gfx/layers/ipc/CompositorParent.cpp
gfx/layers/opengl/LayerManagerOGL.cpp
widget/public/nsIWidget.h
widget/src/cocoa/nsChildView.mm
widget/src/xpwidgets/nsBaseWidget.cpp
--- a/gfx/gl/GLContextProviderCGL.mm
+++ b/gfx/gl/GLContextProviderCGL.mm
@@ -43,18 +43,16 @@
 #include "gfxASurface.h"
 #include "gfxImageSurface.h"
 #include "gfxQuartzSurface.h"
 #include "gfxPlatform.h"
 #include "gfxFailure.h"
 #include "prenv.h"
 #include "mozilla/Preferences.h"
 
-NSOpenGLContext* nsGLContext;
-
 namespace mozilla {
 namespace gl {
 
 static bool gUseDoubleBufferedWindows = true;
 
 class CGLLibrary
 {
 public:
@@ -441,28 +439,27 @@ GLContextProviderCGL::CreateForWindow(ns
     GLContextCGL *shareContext = GetGlobalContextCGL();
 
     NSOpenGLContext *context = [[NSOpenGLContext alloc] 
                                 initWithFormat:sCGLLibrary.PixelFormat()
                                 shareContext:(shareContext ? shareContext->mContext : NULL)];
     if (!context) {
         return nsnull;
     }
-    nsGLContext = context;
 
     NSView *childView = (NSView *)aWidget->GetNativeData(NS_NATIVE_WIDGET);
     [context setView:childView];
 
     // make the context transparent
     nsRefPtr<GLContextCGL> glContext = new GLContextCGL(ContextFormat(ContextFormat::BasicRGB24),
                                                         shareContext,
                                                         context);
     if (!glContext->Init()) {
         return nsnull;
-    }
+    }    
 
     return glContext.forget();
 }
 
 static already_AddRefed<GLContextCGL>
 CreateOffscreenPBufferContext(const gfxIntSize& aSize,
                               const ContextFormat& aFormat,
                               bool aShare = false)
--- a/gfx/layers/basic/BasicLayers.cpp
+++ b/gfx/layers/basic/BasicLayers.cpp
@@ -1608,17 +1608,17 @@ BasicLayerManager::EndTransactionInterna
         ApplyDoubleBuffering(mRoot, clipRect);
       }
     }
 
     PaintLayer(mTarget, mRoot, aCallback, aCallbackData, nsnull);
 
     if (!mTransactionIncomplete) {
       // Clear out target if we have a complete transaction.
-      //mTarget = nsnull;
+      mTarget = nsnull;
     }
   }
 
 #ifdef MOZ_LAYERS_HAVE_LOG
   Log();
   MOZ_LAYERS_LOG(("]----- EndTransaction"));
 #endif
 
@@ -2350,17 +2350,16 @@ BasicShadowableThebesLayer::PaintBuffer(
   } else {
     updatedRegion = aRegionToDraw;
   }
 
   NS_ASSERTION(mBuffer.BufferRect().Contains(aRegionToDraw.GetBounds()),
                "Update outside of buffer rect!");
   NS_ABORT_IF_FALSE(IsSurfaceDescriptorValid(mBackBuffer),
                     "should have a back buffer by now");
-
   BasicManager()->PaintedThebesBuffer(BasicManager()->Hold(this),
                                       updatedRegion,
                                       mBuffer.BufferRect(),
                                       mBuffer.BufferRotation(),
                                       mBackBuffer);
 }
 
 already_AddRefed<gfxASurface>
--- a/gfx/layers/ipc/CompositorChild.cpp
+++ b/gfx/layers/ipc/CompositorChild.cpp
@@ -85,17 +85,16 @@ CompositorChild::CreateCompositor(LayerM
   }
 
   return NULL;
 }
 
 bool
 CompositorChild::RecvNativeContextCreated(const NativeContext &aNativeContext)
 {
-  printf("Got native context for %p\n", mLayerManager->AsShadowManager());
   void *nativeContext = (void*)aNativeContext.nativeContext();
   ShadowNativeContextUserData *userData = new ShadowNativeContextUserData(nativeContext);
   mLayerManager->AsShadowManager()->SetUserData(&sShadowNativeContext, userData);
   return true;
 }
 
 PLayersChild*
 CompositorChild::AllocPLayers(const LayersBackend &backend, const WidgetDescriptor &widget)
--- a/gfx/layers/ipc/CompositorParent.cpp
+++ b/gfx/layers/ipc/CompositorParent.cpp
@@ -56,31 +56,28 @@ CompositorParent::~CompositorParent()
   MOZ_COUNT_DTOR(CompositorParent);
 }
 
 bool
 CompositorParent::AnswerInit()
 {
   CancelableTask *composeTask = NewRunnableMethod(this, &CompositorParent::Composite);
   MessageLoop::current()->PostTask(FROM_HERE, composeTask);
-  printf("init\n");
   return true;
 }
 
 void
 CompositorParent::Composite()
 {
   CancelableTask *composeTask = NewRunnableMethod(this, &CompositorParent::Composite);
   MessageLoop::current()->PostTask(FROM_HERE, composeTask);
 
-  printf("enter compose\n");
   if (!mLayerManager)
     return;
 
-  printf("Compose\n");
   mLayerManager->EndEmptyTransaction();
 
 }
 
 PLayersParent*
 CompositorParent::AllocPLayers(const LayersBackend &backend, const WidgetDescriptor &widget)
 {
   if (widget.type() != WidgetDescriptor::TViewWidget) {
--- a/gfx/layers/opengl/LayerManagerOGL.cpp
+++ b/gfx/layers/opengl/LayerManagerOGL.cpp
@@ -781,62 +781,48 @@ LayerManagerOGL::Render()
   SetupBackBuffer(width, height);
   SetupPipeline(width, height, ApplyWorldTransform);
 
   // Default blend function implements "OVER"
   mGLContext->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA,
                                  LOCAL_GL_ONE, LOCAL_GL_ONE);
   mGLContext->fEnable(LOCAL_GL_BLEND);
 
-  const nsIntRect *clipRect = NULL;// = mRoot->GetClipRect();
+  const nsIntRect *clipRect = mRoot->GetClipRect();
 
   if (clipRect) {
     nsIntRect r = *clipRect;
     WorldTransformRect(r);
     mGLContext->fScissor(r.x, r.y, r.width, r.height);
   } else {
     mGLContext->fScissor(0, 0, width, height);
   }
 
-  //mGLContext->fEnable(LOCAL_GL_SCISSOR_TEST);
+  mGLContext->fEnable(LOCAL_GL_SCISSOR_TEST);
 
   mGLContext->fClearColor(0.0, 0.0, 0.0, 0.0);
   mGLContext->fClear(LOCAL_GL_COLOR_BUFFER_BIT | LOCAL_GL_DEPTH_BUFFER_BIT);
-/*
-  ShadowLayer *shadow = RootLayer()->GetLayer()->AsShadowLayer();
-  if (shadow) {
-    shadow->SetShadowVisibleRegion(nsIntRect(0, 0, width, height));
-    for (Layer* child = RootLayer()->GetLayer()->GetFirstChild(); child; child = child->GetNextSibling()) {
-      for (Layer* child2 = child->GetFirstChild(); child2; child2 = child2->GetNextSibling()) {
-      for (Layer* child3 = child2->GetFirstChild(); child3; child3 = child3->GetNextSibling()) {
-       child3->AsShadowLayer()->SetShadowVisibleRegion(nsIntRect(0, 0, width, height));
-      }
-       child2->AsShadowLayer()->SetShadowVisibleRegion(nsIntRect(0, 0, width, height));
-      }
-     child->AsShadowLayer()->SetShadowVisibleRegion(nsIntRect(0, 0, width, height));
-    }
-  }
-*/
+
   // Render our layers.
   RootLayer()->RenderLayer(mGLContext->IsDoubleBuffered() ? 0 : mBackBufferFBO,
                            nsIntPoint(0, 0));
                            
   mWidget->DrawOver(this, rect);
 
   if (mTarget) {
     CopyToTarget();
     mGLContext->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, 0);
     return;
   }
 
   if (sDrawFPS) {
     mFPS.DrawFPS(mGLContext, GetCopy2DProgram());
   }
 
-  if (true || mGLContext->IsDoubleBuffered()) {
+  if (mGLContext->IsDoubleBuffered()) {
     mGLContext->SwapBuffers();
     mGLContext->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, 0);
     return;
   }
 
   mGLContext->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0);
 
   mGLContext->fActiveTexture(LOCAL_GL_TEXTURE0);
--- a/widget/public/nsIWidget.h
+++ b/widget/public/nsIWidget.h
@@ -105,17 +105,16 @@ typedef nsEventStatus (* EVENT_CALLBACK)
 #define NS_NATIVE_SCREEN      9
 #define NS_NATIVE_SHELLWIDGET 10      // Get the shell GtkWidget
 // Has to match to NPNVnetscapeWindow, and shareable across processes
 // HWND on Windows and XID on X11
 #define NS_NATIVE_SHAREABLE_WINDOW 11
 #ifdef XP_MACOSX
 #define NS_NATIVE_PLUGIN_PORT_QD    100
 #define NS_NATIVE_PLUGIN_PORT_CG    101
-#define NS_NATIVE_OPENGL_VIEW_PTR   102
 #endif
 #ifdef XP_WIN
 #define NS_NATIVE_TSF_THREAD_MGR       100
 #define NS_NATIVE_TSF_CATEGORY_MGR     101
 #define NS_NATIVE_TSF_DISPLAY_ATTR_MGR 102
 #endif
 
 #define NS_IWIDGET_IID \
--- a/widget/src/cocoa/nsChildView.mm
+++ b/widget/src/cocoa/nsChildView.mm
@@ -166,18 +166,16 @@ PRUint32 nsChildView::sLastInputEventCou
 - (void)setPluginEventModel:(NPEventModel)eventModel;
 - (void)setPluginDrawingModel:(NPDrawingModel)drawingModel;
 - (NPDrawingModel)pluginDrawingModel;
 
 - (BOOL)isRectObscuredBySubview:(NSRect)inRect;
 
 - (void)processPendingRedraws;
 
-- (void*)getGLContextPtr;
-
 - (void)drawRect:(NSRect)aRect inContext:(CGContextRef)aContext;
 
 // Called using performSelector:withObject:afterDelay:0 to release
 // aWidgetArray (and its contents) the next time through the run loop.
 - (void)releaseWidgets:(NSArray*)aWidgetArray;
 
 #if USE_CLICK_HOLD_CONTEXTMENU
  // called on a timer two seconds after a mouse down to see if we should display
@@ -528,20 +526,16 @@ void* nsChildView::GetNativeData(PRUint3
       if (aDataType != NS_NATIVE_PLUGIN_PORT_CG) {
         retVal = (void*)&mPluginQDPort;
         break;
       }
 #endif
       retVal = (void*)&mPluginCGContext;
       break;
     }
-    case NS_NATIVE_OPENGL_VIEW_PTR:
-    {
-      retVal = [(ChildView*)mView getGLContextPtr];
-    }
   }
 
   return retVal;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSNULL;
 }
 
 #pragma mark -
@@ -2111,21 +2105,16 @@ NSEvent* gLastDragMouseDownEvent = nil;
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   [mGLContext clearDrawable];
   [mGLContext setView:self];
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
-- (void*)getGLContextPtr
-{
-  return &mGLContext;
-}
-
 - (void)setGLContext:(NSOpenGLContext *)aGLContext
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   mGLContext = aGLContext;
   [mGLContext retain];
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
@@ -2574,53 +2563,44 @@ NSEvent* gLastDragMouseDownEvent = nil;
     if ([cview isPluginView] && [cview pluginDrawingModel] == NPDrawingModelQuickDraw) {
       NSRect frame = [view frame];
       paintEvent.region.Sub(paintEvent.region,
         nsIntRect(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height));
     }
   }
 #endif
 
-  printf("widget ref %p\n", mGeckoChild->GetLayerManager(nsnull)->AsShadowManager());
   LayerManager *layerManager = mGeckoChild->GetLayerManager(nsnull);
-  if (layerManager->GetBackendType() == LayerManager::LAYERS_OPENGL) {
-    LayerManagerOGL *manager = static_cast<LayerManagerOGL*>(layerManager);
-    manager->SetClippingRegion(paintEvent.region);
+  if (layerManager->GetBackendType() == LayerManager::LAYERS_OPENGL ||
+      (layerManager->AsShadowManager() &&
+             layerManager->GetUserData(&compositor::sShadowNativeContext))) {
+    NSOpenGLContext *glContext;
+    if (layerManager->GetBackendType() == LayerManager::LAYERS_OPENGL) {
+      LayerManagerOGL *manager = static_cast<LayerManagerOGL*>(layerManager);
+      manager->SetClippingRegion(paintEvent.region);
+      glContext = (NSOpenGLContext *)manager->gl()->GetNativeData(mozilla::gl::GLContext::NativeGLContext);
+    } else {
+      ShadowNativeContextUserData *userData =
+        (ShadowNativeContextUserData*)layerManager->GetUserData(&compositor::sShadowNativeContext);
+      glContext = (NSOpenGLContext*)userData->GetNativeContext();
+    }
+
     if (!mGLContext) {
-      NSOpenGLContext *glContext =
-          (NSOpenGLContext *)manager->gl()->GetNativeData(mozilla::gl::GLContext::NativeGLContext);
       [self setGLContext:glContext];
     }
     mGeckoChild->DispatchWindowEvent(paintEvent);
 
     // Force OpenGL to refresh the very first time we draw. This works around a
     // Mac OS X bug that stops windows updating on OS X when we use OpenGL.
     if (!mDidForceRefreshOpenGL) {
       [self performSelector:@selector(forceRefreshOpenGL) withObject:nil afterDelay:0];
       mDidForceRefreshOpenGL = YES;
     }
 
     return;
-  } else if (layerManager->AsShadowManager() &&
-             layerManager->GetUserData(&compositor::sShadowNativeContext)) {
-    if (!mGLContext) {
-      ShadowNativeContextUserData *userData =
-        (ShadowNativeContextUserData*)layerManager->GetUserData(&compositor::sShadowNativeContext);
-      NSOpenGLContext *glContext = (NSOpenGLContext*)userData->GetNativeContext();
-      [self setGLContext:glContext];
-      printf("Set context\n");
-    }
-    mGeckoChild->DispatchWindowEvent(paintEvent);
-
-    // Force OpenGL to refresh the very first time we draw. This works around a
-    // Mac OS X bug that stops windows updating on OS X when we use OpenGL.
-    if (!mDidForceRefreshOpenGL) {
-      [self performSelector:@selector(forceRefreshOpenGL) withObject:nil afterDelay:0];
-      mDidForceRefreshOpenGL = YES;
-    }
   }
 
   // Create Cairo objects.
   NSSize bufferSize = [self bounds].size;
   nsRefPtr<gfxQuartzSurface> targetSurface =
     new gfxQuartzSurface(aContext, gfxSize(bufferSize.width, bufferSize.height));
   targetSurface->SetAllowUseAsSource(false);
 
--- a/widget/src/xpwidgets/nsBaseWidget.cpp
+++ b/widget/src/xpwidgets/nsBaseWidget.cpp
@@ -34,17 +34,16 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "mozilla/Util.h"
 
 #include "mozilla/layers/CompositorChild.h"
-#include "mozilla/layers/CompositorParent.h"
 #include "nsBaseWidget.h"
 #include "nsDeviceContext.h"
 #include "nsCOMPtr.h"
 #include "nsGfxCIID.h"
 #include "nsWidgetsCID.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIScreenManager.h"
 #include "nsAppDirectoryServiceDefs.h"
@@ -53,17 +52,16 @@
 #include "nsIServiceManager.h"
 #include "mozilla/Preferences.h"
 #include "BasicLayers.h"
 #include "LayerManagerOGL.h"
 #include "nsIXULRuntime.h"
 #include "nsIGfxInfo.h"
 #include "npapi.h"
 
-
 #ifdef DEBUG
 #include "nsIObserver.h"
 
 static void debug_RegisterPrefCallbacks();
 
 static bool debug_InSecureKeyboardInputMode = false;
 #endif
 
@@ -861,17 +859,16 @@ LayerManager* nsBaseWidget::GetLayerMana
 
           if (shadowManager) {
             ShadowLayerForwarder* lf = lm->AsShadowForwarder();
             if (!lf) {
               delete lm;
               delete compositorChild;
             }
             lf->SetShadowManager(shadowManager);
-            printf("Async layer manager\n");
 
             mLayerManager = lm;
           } else {
             NS_WARNING("fail to construct LayersChild");
             delete compositorChild;
           }
         }
       }