Bug 944938 - Create an APZCTM controller for the compositor parent on Mac with APZ enabled. r=smichaud

This commit is contained in:
Markus Stange 2014-06-04 14:44:27 +02:00
Родитель e1d451f038
Коммит 5f6268eb56
2 изменённых файлов: 46 добавлений и 0 удалений

Просмотреть файл

@ -95,6 +95,7 @@ class RectTextureImage;
namespace mozilla {
namespace layers {
class GLManager;
class APZCTreeManager;
}
}
@ -437,6 +438,7 @@ class nsChildView : public nsBaseWidget,
{
private:
typedef nsBaseWidget Inherited;
typedef mozilla::layers::APZCTreeManager APZCTreeManager;
public:
nsChildView();
@ -572,6 +574,7 @@ public:
already_AddRefed<mozilla::a11y::Accessible> GetDocumentAccessible();
#endif
virtual CompositorParent* NewCompositorParent(int aSurfaceWidth, int aSurfaceHeight);
virtual void CreateCompositor();
virtual gfxASurface* GetThebesSurface();
virtual void PrepareWindowEffects() MOZ_OVERRIDE;
@ -627,6 +630,8 @@ public:
void EndRemoteDrawing() MOZ_OVERRIDE;
void CleanupRemoteDrawing() MOZ_OVERRIDE;
APZCTreeManager* APZCTM() { return mAPZCTreeManager; }
protected:
void ReportMoveEvent();
@ -727,6 +732,8 @@ protected:
// surface to the screen using an OpenGL context.
nsAutoPtr<GLPresenter> mGLPresenter;
nsRefPtr<APZCTreeManager> mAPZCTreeManager;
static uint32_t sLastInputEventCount;
void ReleaseTitlebarCGContext();

Просмотреть файл

@ -65,11 +65,13 @@
#include "GLUploadHelpers.h"
#include "ScopedGLHelpers.h"
#include "HeapCopyOfStackArray.h"
#include "mozilla/layers/APZCTreeManager.h"
#include "mozilla/layers/GLManager.h"
#include "mozilla/layers/CompositorOGL.h"
#include "mozilla/layers/CompositorParent.h"
#include "mozilla/layers/BasicCompositor.h"
#include "gfxUtils.h"
#include "gfxPrefs.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/BorrowedContext.h"
#ifdef ACCESSIBILITY
@ -137,6 +139,8 @@ bool gUserCancelledDrag = false;
uint32_t nsChildView::sLastInputEventCount = 0;
static uint32_t gNumberOfWidgetsNeedingEventThread = 0;
@interface ChildView(Private)
// sets up our view, attaching it to its owning gecko view
@ -190,6 +194,8 @@ uint32_t nsChildView::sLastInputEventCount = 0;
- (id<mozAccessible>)accessible;
#endif
- (APZCTreeManager*)apzctm;
- (BOOL)inactiveWindowAcceptsMouseEvent:(NSEvent*)aEvent;
@end
@ -485,6 +491,13 @@ nsChildView::~nsChildView()
DestroyCompositor();
if (mAPZCTreeManager) {
gNumberOfWidgetsNeedingEventThread--;
if (gNumberOfWidgetsNeedingEventThread == 0) {
[EventThreadRunner stop];
}
}
// An nsChildView object that was in use can be destroyed without Destroy()
// ever being called on it. So we also need to do a quick, safe cleanup
// here (it's too late to just call Destroy(), which can cause crashes).
@ -2098,6 +2111,27 @@ nsChildView::CreateCompositor()
}
}
CompositorParent*
nsChildView::NewCompositorParent(int aSurfaceWidth, int aSurfaceHeight)
{
CompositorParent *compositor = nsBaseWidget::NewCompositorParent(aSurfaceWidth, aSurfaceHeight);
if (gfxPrefs::AsyncPanZoomEnabled()) {
uint64_t rootLayerTreeId = compositor->RootLayerTreeId();
nsRefPtr<APZCTMController> controller = new APZCTMController();
CompositorParent::SetControllerForLayerTree(rootLayerTreeId, controller);
mAPZCTreeManager = CompositorParent::GetAPZCTreeManager(rootLayerTreeId);
mAPZCTreeManager->SetDPI(GetDPI());
if (gNumberOfWidgetsNeedingEventThread == 0) {
[EventThreadRunner start];
}
gNumberOfWidgetsNeedingEventThread++;
}
return compositor;
}
gfxASurface*
nsChildView::GetThebesSurface()
{
@ -5772,6 +5806,11 @@ static int32_t RoundUp(double aDouble)
return NSDragOperationNone;
}
- (APZCTreeManager*)apzctm
{
return mGeckoChild ? mGeckoChild->APZCTM() : nullptr;
}
// This is a utility function used by NSView drag event methods
// to send events. It contains all of the logic needed for Gecko
// dragging to work. Returns the appropriate cocoa drag operation code.