Bug 595277 - Part 2: Add parameter to specify requiring the permanent LayerManager. r=roc

This commit is contained in:
Bas Schouten 2010-12-07 03:05:52 +01:00
Родитель 8d14c56d1c
Коммит 09489b3cb2
16 изменённых файлов: 79 добавлений и 24 удалений

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

@ -1682,6 +1682,23 @@ public:
static already_AddRefed<mozilla::layers::LayerManager>
LayerManagerForDocument(nsIDocument *aDoc);
/**
* Returns a layer manager to use for the given document. Basically we
* look up the document hierarchy for the first document which has
* a presentation with an associated widget, and use that widget's
* layer manager. In addition to the normal layer manager lookup this will
* specifically request a persistent layer manager. This means that the layer
* manager is expected to remain the layer manager for the document in the
* forseeable future. This function should be used carefully as it may change
* the document's layer manager.
*
* If one can't be found, a BasicLayerManager is created and returned.
*
* @param aDoc the document for which to return a layer manager.
*/
static already_AddRefed<mozilla::layers::LayerManager>
PersistentLayerManagerForDocument(nsIDocument *aDoc);
/**
* Determine whether a content node is focused or not,
*
@ -1715,7 +1732,6 @@ public:
static bool AllowXULXBLForPrincipal(nsIPrincipal* aPrincipal);
private:
static PRBool InitializeEventTable();
static nsresult EnsureStringBundle(PropertiesFile aFile);

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

@ -6370,8 +6370,8 @@ nsContentUtils::PlatformToDOMLineBreaks(nsString &aString)
}
}
already_AddRefed<LayerManager>
nsContentUtils::LayerManagerForDocument(nsIDocument *aDoc)
static already_AddRefed<LayerManager>
LayerManagerForDocumentInternal(nsIDocument *aDoc, bool aRequirePersistent)
{
nsIDocument* doc = aDoc;
nsIDocument* displayDoc = doc->GetDisplayDocument();
@ -6405,7 +6405,10 @@ nsContentUtils::LayerManagerForDocument(nsIDocument *aDoc)
nsIWidget* widget =
nsLayoutUtils::GetDisplayRootFrame(rootFrame)->GetNearestWidget();
if (widget) {
nsRefPtr<LayerManager> manager = widget->GetLayerManager();
nsRefPtr<LayerManager> manager =
static_cast<nsIWidget_MOZILLA_2_0_BRANCH*>(widget)->
GetLayerManager(aRequirePersistent ? nsIWidget_MOZILLA_2_0_BRANCH::LAYER_MANAGER_PERSISTENT :
nsIWidget_MOZILLA_2_0_BRANCH::LAYER_MANAGER_CURRENT);
return manager.forget();
}
}
@ -6415,6 +6418,18 @@ nsContentUtils::LayerManagerForDocument(nsIDocument *aDoc)
return manager.forget();
}
already_AddRefed<LayerManager>
nsContentUtils::LayerManagerForDocument(nsIDocument *aDoc)
{
return LayerManagerForDocumentInternal(aDoc, false);
}
already_AddRefed<LayerManager>
nsContentUtils::PersistentLayerManagerForDocument(nsIDocument *aDoc)
{
return LayerManagerForDocumentInternal(aDoc, true);
}
bool
nsContentUtils::AllowXULXBLForPrincipal(nsIPrincipal* aPrincipal)
{

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

@ -1369,6 +1369,8 @@ class nsIWidget_MOZILLA_2_0_BRANCH : public nsIWidget {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWIDGET_MOZILLA_2_0_BRANCH_IID)
typedef mozilla::layers::LayerManager LayerManager;
/*
* Notifies the IME if the input context changes.
*
@ -1381,6 +1383,15 @@ class nsIWidget_MOZILLA_2_0_BRANCH : public nsIWidget {
* Get IME is 'Enabled' or 'Disabled' or 'Password' and other input context
*/
NS_IMETHOD GetInputMode(IMEContext& aContext) = 0;
enum LayerManagerPersistence
{
LAYER_MANAGER_CURRENT = 0,
LAYER_MANAGER_PERSISTENT
};
virtual LayerManager *GetLayerManager(LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
bool* aAllowRetaining = nsnull) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIWidget_MOZILLA_2_0_BRANCH, NS_IWIDGET_MOZILLA_2_0_BRANCH_IID)

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

@ -657,7 +657,7 @@ nsWindow::SetWindowClass(const nsAString& xulWinType)
}
mozilla::layers::LayerManager*
nsWindow::GetLayerManager(bool* aAllowRetaining)
nsWindow::GetLayerManager(LayerManagerPersistence, bool* aAllowRetaining)
{
if (aAllowRetaining) {
*aAllowRetaining = true;
@ -868,7 +868,7 @@ nsWindow::DrawTo(gfxASurface *targetSurface)
nsPaintEvent event(PR_TRUE, NS_PAINT, this);
event.region = boundsRect;
switch (GetLayerManager()->GetBackendType()) {
switch (GetLayerManager(nsnull)->GetBackendType()) {
case LayerManager::LAYERS_BASIC: {
nsRefPtr<gfxContext> ctx = new gfxContext(targetSurface);
@ -891,7 +891,7 @@ nsWindow::DrawTo(gfxASurface *targetSurface)
}
case LayerManager::LAYERS_OPENGL: {
static_cast<mozilla::layers::LayerManagerOGL*>(GetLayerManager())->
static_cast<mozilla::layers::LayerManagerOGL*>(GetLayerManager(nsnull))->
SetClippingRegion(nsIntRegion(boundsRect));
status = DispatchEvent(&event);
@ -960,7 +960,7 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
AndroidBridge::Bridge()->HideProgressDialogOnce();
if (GetLayerManager()->GetBackendType() == LayerManager::LAYERS_BASIC) {
if (GetLayerManager(nsnull)->GetBackendType() == LayerManager::LAYERS_BASIC) {
jobject bytebuf = sview.GetSoftwareDrawBuffer();
if (!bytebuf) {
ALOG("no buffer to draw into - skipping draw");

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

@ -55,6 +55,8 @@ class nsWindow :
public nsBaseWidget
{
public:
using nsBaseWidget::GetLayerManager;
nsWindow();
virtual ~nsWindow();
@ -162,7 +164,8 @@ public:
NS_IMETHOD OnIMESelectionChange(void);
virtual nsIMEUpdatePreference GetIMEUpdatePreference();
LayerManager* GetLayerManager(bool* aAllowRetaining = nsnull);
LayerManager* GetLayerManager(LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
bool* aAllowRetaining = nsnull);
gfxASurface* GetThebesSurface();
NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent);

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

@ -2718,8 +2718,8 @@ NSEvent* gLastDragMouseDownEvent = nil;
}
#endif
if (mGeckoChild->GetLayerManager()->GetBackendType() == LayerManager::LAYERS_OPENGL) {
LayerManagerOGL *manager = static_cast<LayerManagerOGL*>(mGeckoChild->GetLayerManager());
if (mGeckoChild->GetLayerManager(nsnull)->GetBackendType() == LayerManager::LAYERS_OPENGL) {
LayerManagerOGL *manager = static_cast<LayerManagerOGL*>(mGeckoChild->GetLayerManager(nsnull));
manager->SetClippingRegion(paintEvent.region);
if (!mGLContext) {
mGLContext = (NSOpenGLContext *)manager->gl()->GetNativeData(mozilla::gl::GLContext::NativeGLContext);

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

@ -258,7 +258,8 @@ public:
NS_IMETHOD Invalidate(const nsIntRect &aRect, PRBool aIsSynchronous);
NS_IMETHOD Update();
virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations);
virtual LayerManager* GetLayerManager(bool* aAllowRetaining = nsnull);
virtual LayerManager* GetLayerManager(LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
bool* aAllowRetaining = nsnull);
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus) ;
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, nsIMenuRollup * aMenuRollup,
PRBool aDoCapture, PRBool aConsumeRollupEvent);

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

@ -932,7 +932,7 @@ nsCocoaWindow::ConfigureChildren(const nsTArray<Configuration>& aConfigurations)
}
LayerManager*
nsCocoaWindow::GetLayerManager(bool* aAllowRetaining)
nsCocoaWindow::GetLayerManager(LayerManagerPersistence, bool* aAllowRetaining)
{
if (mPopupContentView) {
return mPopupContentView->GetLayerManager(aAllowRetaining);

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

@ -2154,9 +2154,9 @@ nsWindow::OnExposeEvent(GtkWidget *aWidget, GdkEventExpose *aEvent)
return TRUE;
}
if (GetLayerManager()->GetBackendType() == LayerManager::LAYERS_OPENGL)
if (GetLayerManager(nsnull)->GetBackendType() == LayerManager::LAYERS_OPENGL)
{
LayerManagerOGL *manager = static_cast<LayerManagerOGL*>(GetLayerManager());
LayerManagerOGL *manager = static_cast<LayerManagerOGL*>(GetLayerManager(nsnull));
manager->SetClippingRegion(event.region);
nsEventStatus status;

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

@ -1014,12 +1014,12 @@ nsWindow::DoPaint(QPainter* aPainter, const QStyleOptionGraphicsItem* aOption, Q
nsEventStatus status;
nsIntRect rect(r.x(), r.y(), r.width(), r.height());
if (GetLayerManager()->GetBackendType() == LayerManager::LAYERS_OPENGL) {
if (GetLayerManager(nsnull)->GetBackendType() == LayerManager::LAYERS_OPENGL) {
nsPaintEvent event(PR_TRUE, NS_PAINT, this);
event.refPoint.x = r.x();
event.refPoint.y = r.y();
event.region = nsIntRegion(rect);
static_cast<mozilla::layers::LayerManagerOGL*>(GetLayerManager())->
static_cast<mozilla::layers::LayerManagerOGL*>(GetLayerManager(nsnull))->
SetClippingRegion(event.region);
return DispatchEvent(&event);
}

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

@ -3208,7 +3208,7 @@ nsWindow::HasPendingInputEvent()
**************************************************************/
mozilla::layers::LayerManager*
nsWindow::GetLayerManager(bool* aAllowRetaining)
nsWindow::GetLayerManager(LayerManagerPersistence aPersistence, bool* aAllowRetaining)
{
if (aAllowRetaining) {
*aAllowRetaining = true;

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

@ -166,7 +166,7 @@ public:
PRBool aDoCapture, PRBool aConsumeRollupEvent);
NS_IMETHOD GetAttention(PRInt32 aCycleCount);
virtual PRBool HasPendingInputEvent();
virtual LayerManager* GetLayerManager(bool* aAllowRetaining = nsnull);
virtual LayerManager* GetLayerManager(LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT, bool* aAllowRetaining = nsnull);
gfxASurface *GetThebesSurface();
NS_IMETHOD OnDefaultButtonLoaded(const nsIntRect &aButtonRect);
NS_IMETHOD OverrideSystemMouseScrollSpeed(PRInt32 aOriginalDelta, PRBool aIsHorizontal, PRInt32 &aOverriddenDelta);

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

@ -315,7 +315,7 @@ PuppetWidget::DispatchEvent(nsGUIEvent* event, nsEventStatus& aStatus)
}
LayerManager*
PuppetWidget::GetLayerManager(bool* aAllowRetaining)
PuppetWidget::GetLayerManager(LayerManagerPersistence, bool* aAllowRetaining)
{
if (!mLayerManager) {
mLayerManager = new BasicShadowLayerManager(this);

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

@ -164,7 +164,8 @@ public:
//
//NS_IMETHOD CaptureMouse(PRBool aCapture);
virtual LayerManager* GetLayerManager(bool* aAllowRetaining = nsnull);
virtual LayerManager* GetLayerManager(LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
bool* aAllowRetaining = nsnull);
// virtual nsIDeviceContext* GetDeviceContext();
virtual gfxASurface* GetThebesSurface();

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

@ -747,7 +747,7 @@ nsBaseWidget::AutoLayerManagerSetup::AutoLayerManagerSetup(
: mWidget(aWidget)
{
BasicLayerManager* manager =
static_cast<BasicLayerManager*>(mWidget->GetLayerManager());
static_cast<BasicLayerManager*>(mWidget->GetLayerManager(nsnull));
if (manager) {
NS_ASSERTION(manager->GetBackendType() == LayerManager::LAYERS_BASIC,
"AutoLayerManagerSetup instantiated for non-basic layer backend!");
@ -758,7 +758,7 @@ nsBaseWidget::AutoLayerManagerSetup::AutoLayerManagerSetup(
nsBaseWidget::AutoLayerManagerSetup::~AutoLayerManagerSetup()
{
BasicLayerManager* manager =
static_cast<BasicLayerManager*>(mWidget->GetLayerManager());
static_cast<BasicLayerManager*>(mWidget->GetLayerManager(nsnull));
if (manager) {
NS_ASSERTION(manager->GetBackendType() == LayerManager::LAYERS_BASIC,
"AutoLayerManagerSetup instantiated for non-basic layer backend!");
@ -811,6 +811,12 @@ nsBaseWidget::GetShouldAccelerate()
}
LayerManager* nsBaseWidget::GetLayerManager(bool* aAllowRetaining)
{
return GetLayerManager(LAYER_MANAGER_CURRENT, aAllowRetaining);
}
LayerManager* nsBaseWidget::GetLayerManager(LayerManagerPersistence,
bool* aAllowRetaining)
{
if (!mLayerManager) {
nsCOMPtr<nsIPrefBranch2> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);

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

@ -115,7 +115,9 @@ public:
NS_IMETHOD MakeFullScreen(PRBool aFullScreen);
virtual nsIDeviceContext* GetDeviceContext();
virtual nsIToolkit* GetToolkit();
virtual LayerManager* GetLayerManager(bool* aAllowRetaining = nsnull);
virtual LayerManager* GetLayerManager(bool *aAllowRetaining = nsnull);
virtual LayerManager* GetLayerManager(LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
bool* aAllowRetaining = nsnull);
virtual gfxASurface* GetThebesSurface();
NS_IMETHOD SetModal(PRBool aModal);
NS_IMETHOD SetWindowClass(const nsAString& xulWinType);