Bug 945203. Part 1: Add Layers API to annotate layers with hit-test regions. r=kats

--HG--
extra : rebase_source : baa695c0d6104f620a5b45a83e5b230ef584abd9
This commit is contained in:
Robert O'Callahan 2013-12-16 23:47:06 +13:00
parent 71ac1019d5
commit 273ddfc1ac
8 changed files with 89 additions and 1 deletions

View File

@ -685,6 +685,24 @@ struct ParamTraits<mozilla::layers::ScrollableLayerGuid>
}
};
template <>
struct ParamTraits<mozilla::layers::EventRegions>
{
typedef mozilla::layers::EventRegions paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, aParam.mHitRegion);
WriteParam(aMsg, aParam.mDispatchToContentHitRegion);
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
return (ReadParam(aMsg, aIter, &aResult->mHitRegion) &&
ReadParam(aMsg, aIter, &aResult->mDispatchToContentHitRegion));
}
};
} /* namespace IPC */
#endif /* __GFXMESSAGEUTILS_H__ */

View File

@ -1261,6 +1261,12 @@ Layer::PrintInfo(nsACString& aTo, const char* aPrefix)
} else {
aTo += " [not visible]";
}
if (!mEventRegions.mHitRegion.IsEmpty()) {
AppendToString(aTo, mEventRegions.mHitRegion, " [hitregion=", "]");
}
if (!mEventRegions.mDispatchToContentHitRegion.IsEmpty()) {
AppendToString(aTo, mEventRegions.mDispatchToContentHitRegion, " [dispatchtocontentregion=", "]");
}
if (1.0 != mOpacity) {
aTo.AppendPrintf(" [opacity=%g]", mOpacity);
}

View File

@ -740,6 +740,38 @@ public:
}
}
/*
* Compositor event handling
* =========================
* When a touch-start event (or similar) is sent to the AsyncPanZoomController,
* it needs to decide whether the event should be sent to the main thread.
* Each layer has a list of event handling regions. When the compositor needs
* to determine how to handle a touch event, it scans the layer tree from top
* to bottom in z-order (traversing children before their parents). Points
* outside the clip region for a layer cause that layer (and its subtree)
* to be ignored. If a layer has a mask layer, and that mask layer's alpha
* value is zero at the event point, then the layer and its subtree should
* be ignored.
* For each layer, if the point is outside its hit region, we ignore the layer
* and move onto the next. If the point is inside its hit region but
* outside the dispatch-to-content region, we can initiate a gesture without
* consulting the content thread. Otherwise we must dispatch the event to
* content.
*/
/**
* CONSTRUCTION PHASE ONLY
* Set the event handling region.
*/
void SetEventRegions(const EventRegions& aRegions)
{
if (mEventRegions != aRegions) {
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) eventregions were %s, now %s", this,
mEventRegions.ToString().get(), aRegions.ToString().get()));
mEventRegions = aRegions;
Mutated();
}
}
/**
* CONSTRUCTION PHASE ONLY
* Set the opacity which will be applied to this layer as it
@ -1008,6 +1040,7 @@ public:
const nsIntRect* GetClipRect() { return mUseClipRect ? &mClipRect : nullptr; }
uint32_t GetContentFlags() { return mContentFlags; }
const nsIntRegion& GetVisibleRegion() { return mVisibleRegion; }
const EventRegions& GetEventRegions() const { return mEventRegions; }
ContainerLayer* GetParent() { return mParent; }
Layer* GetNextSibling() { return mNextSibling; }
const Layer* GetNextSibling() const { return mNextSibling; }
@ -1371,6 +1404,7 @@ protected:
nsRefPtr<Layer> mMaskLayer;
gfx::UserData mUserData;
nsIntRegion mVisibleRegion;
EventRegions mEventRegions;
gfx3DMatrix mTransform;
// A mutation of |mTransform| that we've queued to be applied at the
// end of the next transaction (if nothing else overrides it in the

View File

@ -8,6 +8,7 @@
#include <stdint.h> // for uint32_t
#include "nsPoint.h" // for nsIntPoint
#include "nsRegion.h"
#ifdef MOZ_WIDGET_GONK
#include <ui/GraphicBuffer.h>
@ -126,6 +127,29 @@ enum ScaleMode {
// Unimplemented - SCALE_PRESERVE_ASPECT_RATIO_CONTAIN
};
struct EventRegions {
nsIntRegion mHitRegion;
nsIntRegion mDispatchToContentHitRegion;
bool operator==(const EventRegions& aRegions) const
{
return mHitRegion == aRegions.mHitRegion &&
mDispatchToContentHitRegion == aRegions.mDispatchToContentHitRegion;
}
bool operator!=(const EventRegions& aRegions) const
{
return !(*this == aRegions);
}
nsCString ToString() const
{
nsCString result = mHitRegion.ToString();
result.AppendLiteral(";dispatchToContent=");
result.Append(mDispatchToContentHitRegion.ToString());
return result;
}
};
} // namespace
} // namespace

View File

@ -269,6 +269,7 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
const CommonLayerAttributes& common = attrs.common();
layer->SetVisibleRegion(common.visibleRegion());
layer->SetEventRegions(common.eventRegions());
layer->SetContentFlags(common.contentFlags());
layer->SetOpacity(common.opacity());
layer->SetClipRect(common.useClipRect() ? &common.clipRect() : nullptr);

View File

@ -35,6 +35,7 @@ using mozilla::LayerMargin from "Units.h";
using mozilla::LayerPoint from "Units.h";
using mozilla::LayerRect from "Units.h";
using mozilla::layers::ScaleMode from "mozilla/layers/LayersTypes.h";
using mozilla::layers::EventRegions from "mozilla/layers/LayersTypes.h";
using mozilla::layers::DiagnosticTypes from "mozilla/layers/CompositorTypes.h";
using struct mozilla::layers::FrameMetrics from "FrameMetrics.h";
@ -184,6 +185,7 @@ struct Animation {
// Change a layer's attributes
struct CommonLayerAttributes {
nsIntRegion visibleRegion;
EventRegions eventRegions;
TransformMatrix transform;
float postXScale;
float postYScale;

View File

@ -8,7 +8,6 @@
#ifndef mozilla_layers_ShadowLayerUtilsX11_h
#define mozilla_layers_ShadowLayerUtilsX11_h
#include <X11/X.h> // for Drawable
#include "ipc/IPCMessageUtils.h"
#include "mozilla/GfxMessageUtils.h"
#include "nsCOMPtr.h" // for already_AddRefed
@ -16,6 +15,9 @@
#define MOZ_HAVE_SURFACEDESCRIPTORX11
#define MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS
typedef unsigned long XID;
typedef XID Drawable;
class gfxXlibSurface;
namespace IPC {

View File

@ -486,6 +486,7 @@ ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies, bool
LayerAttributes attrs;
CommonLayerAttributes& common = attrs.common();
common.visibleRegion() = mutant->GetVisibleRegion();
common.eventRegions() = mutant->GetEventRegions();
common.postXScale() = mutant->GetPostXScale();
common.postYScale() = mutant->GetPostYScale();
common.transform() = mutant->GetBaseTransform();