mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Backout changeset 89f35d1fea6c (bug 539356) because of performance and correctness regressions
This commit is contained in:
parent
3c74e1a1e2
commit
78b833f61a
@ -26,16 +26,8 @@ public:
|
||||
/* Attaches untyped userData associated with key. destroy is called on destruction */
|
||||
void Add(UserDataKey *key, void *userData, destroyFunc destroy)
|
||||
{
|
||||
for (int i=0; i<count; i++) {
|
||||
if (key == entries[i].key) {
|
||||
if (entries[i].destroy) {
|
||||
entries[i].destroy(entries[i].userData);
|
||||
}
|
||||
entries[i].userData = userData;
|
||||
entries[i].destroy = destroy;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// XXX we should really warn if user data with key has already been added,
|
||||
// since in that case Get() will return the old user data!
|
||||
|
||||
// We could keep entries in a std::vector instead of managing it by hand
|
||||
// but that would propagate an stl dependency out which we'd rather not
|
||||
@ -82,21 +74,12 @@ public:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Destroy()
|
||||
{
|
||||
for (int i=0; i<count; i++) {
|
||||
if (entries[i].destroy) {
|
||||
entries[i].destroy(entries[i].userData);
|
||||
}
|
||||
}
|
||||
free(entries);
|
||||
entries = NULL;
|
||||
count = 0;
|
||||
}
|
||||
|
||||
~UserData()
|
||||
{
|
||||
Destroy();
|
||||
for (int i=0; i<count; i++) {
|
||||
entries[i].destroy(entries[i].userData);
|
||||
}
|
||||
free(entries);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -167,10 +167,60 @@ public:
|
||||
* BasicLayerManager for such an implementation.
|
||||
*/
|
||||
|
||||
static void LayerManagerUserDataDestroy(void *data)
|
||||
{
|
||||
delete static_cast<LayerUserData*>(data);
|
||||
}
|
||||
/**
|
||||
* Helper class to manage user data for layers and LayerManagers.
|
||||
*/
|
||||
class THEBES_API LayerUserDataSet {
|
||||
public:
|
||||
LayerUserDataSet() : mKey(nsnull) {}
|
||||
|
||||
void Set(void* aKey, LayerUserData* aValue)
|
||||
{
|
||||
NS_ASSERTION(!mKey || mKey == aKey,
|
||||
"Multiple LayerUserData objects not supported");
|
||||
mKey = aKey;
|
||||
mValue = aValue;
|
||||
}
|
||||
/**
|
||||
* This can be used anytime. Ownership passes to the caller!
|
||||
*/
|
||||
LayerUserData* Remove(void* aKey)
|
||||
{
|
||||
if (mKey == aKey) {
|
||||
mKey = nsnull;
|
||||
LayerUserData* d = mValue.forget();
|
||||
return d;
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
/**
|
||||
* This getter can be used anytime.
|
||||
*/
|
||||
bool Has(void* aKey)
|
||||
{
|
||||
return mKey == aKey;
|
||||
}
|
||||
/**
|
||||
* This getter can be used anytime. Ownership is retained by this object.
|
||||
*/
|
||||
LayerUserData* Get(void* aKey)
|
||||
{
|
||||
return mKey == aKey ? mValue.get() : nsnull;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear out current user data.
|
||||
*/
|
||||
void Clear()
|
||||
{
|
||||
mKey = nsnull;
|
||||
mValue = nsnull;
|
||||
}
|
||||
|
||||
private:
|
||||
void* mKey;
|
||||
nsAutoPtr<LayerUserData> mValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* A LayerManager controls a tree of layers. All layers in the tree
|
||||
@ -220,7 +270,7 @@ public:
|
||||
* for its widget going away. After this call, only user data calls
|
||||
* are valid on the layer manager.
|
||||
*/
|
||||
virtual void Destroy() { mDestroyed = true; mUserData.Destroy(); }
|
||||
virtual void Destroy() { mDestroyed = true; mUserData.Clear(); }
|
||||
bool IsDestroyed() { return mDestroyed; }
|
||||
|
||||
virtual ShadowLayerForwarder* AsShadowForwarder()
|
||||
@ -414,32 +464,23 @@ public:
|
||||
* initially null. Ownership pases to the layer manager.
|
||||
*/
|
||||
void SetUserData(void* aKey, LayerUserData* aData)
|
||||
{
|
||||
mUserData.Add(static_cast<gfx::UserDataKey*>(aKey), aData, LayerManagerUserDataDestroy);
|
||||
}
|
||||
{ mUserData.Set(aKey, aData); }
|
||||
/**
|
||||
* This can be used anytime. Ownership passes to the caller!
|
||||
*/
|
||||
nsAutoPtr<LayerUserData> RemoveUserData(void* aKey)
|
||||
{
|
||||
nsAutoPtr<LayerUserData> d(static_cast<LayerUserData*>(mUserData.Remove(static_cast<gfx::UserDataKey*>(aKey))));
|
||||
return d;
|
||||
}
|
||||
{ nsAutoPtr<LayerUserData> d(mUserData.Remove(aKey)); return d; }
|
||||
/**
|
||||
* This getter can be used anytime.
|
||||
*/
|
||||
bool HasUserData(void* aKey)
|
||||
{
|
||||
return GetUserData(aKey);
|
||||
}
|
||||
{ return mUserData.Has(aKey); }
|
||||
/**
|
||||
* This getter can be used anytime. Ownership is retained by the layer
|
||||
* manager.
|
||||
*/
|
||||
LayerUserData* GetUserData(void* aKey)
|
||||
{
|
||||
return static_cast<LayerUserData*>(mUserData.Get(static_cast<gfx::UserDataKey*>(aKey)));
|
||||
}
|
||||
{ return mUserData.Get(aKey); }
|
||||
|
||||
/**
|
||||
* Flag the next paint as the first for a document.
|
||||
@ -489,7 +530,7 @@ public:
|
||||
|
||||
protected:
|
||||
nsRefPtr<Layer> mRoot;
|
||||
gfx::UserData mUserData;
|
||||
LayerUserDataSet mUserData;
|
||||
bool mDestroyed;
|
||||
bool mSnapEffectiveTransforms;
|
||||
|
||||
@ -748,32 +789,23 @@ public:
|
||||
* initially null. Ownership pases to the layer manager.
|
||||
*/
|
||||
void SetUserData(void* aKey, LayerUserData* aData)
|
||||
{
|
||||
mUserData.Add(static_cast<gfx::UserDataKey*>(aKey), aData, LayerManagerUserDataDestroy);
|
||||
}
|
||||
{ mUserData.Set(aKey, aData); }
|
||||
/**
|
||||
* This can be used anytime. Ownership passes to the caller!
|
||||
*/
|
||||
nsAutoPtr<LayerUserData> RemoveUserData(void* aKey)
|
||||
{
|
||||
nsAutoPtr<LayerUserData> d(static_cast<LayerUserData*>(mUserData.Remove(static_cast<gfx::UserDataKey*>(aKey))));
|
||||
return d;
|
||||
}
|
||||
{ nsAutoPtr<LayerUserData> d(mUserData.Remove(aKey)); return d; }
|
||||
/**
|
||||
* This getter can be used anytime.
|
||||
*/
|
||||
bool HasUserData(void* aKey)
|
||||
{
|
||||
return GetUserData(aKey);
|
||||
}
|
||||
{ return mUserData.Has(aKey); }
|
||||
/**
|
||||
* This getter can be used anytime. Ownership is retained by the layer
|
||||
* manager.
|
||||
*/
|
||||
LayerUserData* GetUserData(void* aKey)
|
||||
{
|
||||
return static_cast<LayerUserData*>(mUserData.Get(static_cast<gfx::UserDataKey*>(aKey)));
|
||||
}
|
||||
{ return mUserData.Get(aKey); }
|
||||
|
||||
/**
|
||||
* |Disconnect()| is used by layers hooked up over IPC. It may be
|
||||
@ -959,7 +991,7 @@ protected:
|
||||
Layer* mPrevSibling;
|
||||
void* mImplData;
|
||||
nsRefPtr<Layer> mMaskLayer;
|
||||
gfx::UserData mUserData;
|
||||
LayerUserDataSet mUserData;
|
||||
nsIntRegion mVisibleRegion;
|
||||
gfx3DMatrix mTransform;
|
||||
gfx3DMatrix mEffectiveTransform;
|
||||
|
Loading…
Reference in New Issue
Block a user