Make shadow layer transformations work.

This commit is contained in:
Ali Juma 2011-12-15 15:20:06 -05:00
Родитель c82eb64f48
Коммит 5e62d4fd13
9 изменённых файлов: 93 добавлений и 11 удалений

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

@ -137,6 +137,7 @@ EXPORTS_mozilla/layers = \
ShadowLayers.h \
ShadowLayersChild.h \
ShadowLayersParent.h \
ShadowLayersHost.h \
$(NULL)
CPPSRCS += \

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

@ -108,7 +108,7 @@ CompositorParent::AllocPLayers(const LayersBackend &backend, const WidgetDescrip
mLayerManager = layerManager;
return new ShadowLayersParent(slm);
return new ShadowLayersParent(slm, this);
} else {
NS_ERROR("Unsupported backend selected for Async Compositor");
return NULL;

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

@ -42,13 +42,15 @@
#include "mozilla/layers/PCompositorParent.h"
#include "mozilla/layers/PLayersParent.h"
#include "ShadowLayersHost.h"
class LayerManager;
namespace mozilla {
namespace layers {
class CompositorParent : public PCompositorParent
class CompositorParent : public PCompositorParent,
public ShadowLayersHost
{
NS_INLINE_DECL_REFCOUNTING(CompositorParent)
public:
@ -57,6 +59,9 @@ public:
bool AnswerInit();
virtual mozilla::layout::RenderFrameParent* GetRenderFrameParent() { return NULL; }
virtual CompositorParent* GetCompositorParent() { return this; }
protected:
virtual PLayersParent* AllocPLayers(const LayersBackend &backend, const WidgetDescriptor &widget);

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

@ -0,0 +1,65 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set sw=4 ts=8 et tw=80 : */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Content App.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ali Juma <ajuma@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* 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 ***** */
#ifndef mozilla_layers_ShadowLayersHost_h
#define mozilla_layers_ShadowLayersHost_h
namespace mozilla {
namespace layout {
class RenderFrameParent;
}
namespace layers {
class CompositorParent;
class ShadowLayersHost
{
NS_INLINE_DECL_REFCOUNTING(ShadowLayersHost)
public:
virtual mozilla::layout::RenderFrameParent* GetRenderFrameParent() = 0;
virtual CompositorParent* GetCompositorParent() = 0;
};
} // layers
} // mozilla
#endif // mozilla_layers_ShadowLayersHost_h

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

@ -121,11 +121,12 @@ ShadowChild(const OpRemoveChild& op)
//--------------------------------------------------
// ShadowLayersParent
ShadowLayersParent::ShadowLayersParent(ShadowLayerManager* aManager)
ShadowLayersParent::ShadowLayersParent(ShadowLayerManager* aManager, ShadowLayersHost* aHost)
: mDestroyed(false)
{
MOZ_COUNT_CTOR(ShadowLayersParent);
mLayerManager = aManager;
mHost = aHost;
}
ShadowLayersParent::~ShadowLayersParent()
@ -219,6 +220,11 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
layer->SetClipRect(common.useClipRect() ? &common.clipRect() : NULL);
layer->SetTransform(common.transform());
layer->SetTileSourceRect(common.useTileSourceRect() ? &common.tileSourceRect() : NULL);
if (mHost->GetCompositorParent()) {
layer->AsShadowLayer()->SetShadowTransform(common.transform());
layer->AsShadowLayer()->SetShadowVisibleRegion(common.visibleRegion());
layer->AsShadowLayer()->SetShadowClipRect(layer->GetClipRect());
}
static bool fixedPositionLayersEnabled = getenv("MOZ_ENABLE_FIXED_POSITION_LAYERS") != 0;
if (fixedPositionLayersEnabled) {
layer->SetIsFixedPosition(common.isFixedPosition());
@ -406,9 +412,7 @@ ShadowLayersParent::DeallocPLayer(PLayerParent* actor)
RenderFrameParent*
ShadowLayersParent::Frame()
{
// Fix me, gives: error: Manager was not declared in this scope
//return static_cast<RenderFrameParent*>(Manager());
return NULL;
return mHost->GetRenderFrameParent();
}
void

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

@ -43,6 +43,7 @@
#include "mozilla/layers/PLayersParent.h"
#include "ShadowLayers.h"
#include "ShadowLayersHost.h"
namespace mozilla {
@ -63,7 +64,7 @@ class ShadowLayersParent : public PLayersParent,
typedef InfallibleTArray<EditReply> EditReplyArray;
public:
ShadowLayersParent(ShadowLayerManager* aManager);
ShadowLayersParent(ShadowLayerManager* aManager, ShadowLayersHost* aHost);
~ShadowLayersParent();
void Destroy();
@ -86,6 +87,7 @@ private:
RenderFrameParent* Frame();
nsRefPtr<ShadowLayerManager> mLayerManager;
nsRefPtr<ShadowLayersHost> mHost;
// Hold the root because it might be grafted under various
// containers in the "real" layer tree
nsRefPtr<ContainerLayer> mRoot;

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

@ -800,7 +800,7 @@ LayerManagerOGL::Render()
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));
@ -814,7 +814,7 @@ LayerManagerOGL::Render()
child->AsShadowLayer()->SetShadowVisibleRegion(nsIntRect(0, 0, width, height));
}
}
*/
// Render our layers.
RootLayer()->RenderLayer(mGLContext->IsDoubleBuffered() ? 0 : mBackBufferFBO,
nsIntPoint(0, 0));

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

@ -648,7 +648,7 @@ RenderFrameParent::AllocPLayers(LayerManager::LayersBackend* aBackendType)
return nsnull;
}
*aBackendType = lm->GetBackendType();
return new ShadowLayersParent(slm);
return new ShadowLayersParent(slm, this);
}
bool

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

@ -42,6 +42,7 @@
#define mozilla_layout_RenderFrameParent_h
#include "mozilla/layout/PRenderFrameParent.h"
#include "mozilla/layers/ShadowLayersHost.h"
#include <map>
#include "nsDisplayList.h"
@ -59,7 +60,8 @@ class ShadowLayersParent;
namespace layout {
class RenderFrameParent : public PRenderFrameParent
class RenderFrameParent : public PRenderFrameParent,
public mozilla::layers::ShadowLayersHost
{
typedef mozilla::layers::FrameMetrics FrameMetrics;
typedef mozilla::layers::ContainerLayer ContainerLayer;
@ -100,6 +102,9 @@ public:
void SetBackgroundColor(nscolor aColor) { mBackgroundColor = gfxRGBA(aColor); };
virtual RenderFrameParent* GetRenderFrameParent() { return this; }
virtual mozilla::layers::CompositorParent* GetCompositorParent() { return NULL; }
protected:
NS_OVERRIDE void ActorDestroy(ActorDestroyReason why);