Merge mozilla-central into the branch for asynchronous plugin painting on Windows.

This commit is contained in:
Benjamin Smedberg
2010-11-05 15:56:28 -04:00
579 changed files with 20971 additions and 15080 deletions

View File

@@ -127,6 +127,12 @@ PluginModuleParent::~PluginModuleParent()
{
NS_ASSERTION(OkToCleanup(), "unsafe destruction");
#ifdef OS_MACOSX
if (mCATimer) {
mCATimer->Cancel();
}
#endif
if (!mShutdown) {
NS_WARNING("Plugin host deleted the module without shutting down.");
NPError err;
@@ -890,6 +896,17 @@ PluginModuleParent::RecvPluginHideWindow(const uint32_t& aWindowId)
#ifdef OS_MACOSX
#define DEFAULT_REFRESH_MS 20 // CoreAnimation: 50 FPS
void
CAUpdate(nsITimer *aTimer, void *aClosure) {
nsTObserverArray<PluginInstanceParent*> *ips =
static_cast<nsTObserverArray<PluginInstanceParent*> *>(aClosure);
nsTObserverArray<PluginInstanceParent*>::ForwardIterator iter(*ips);
while (iter.HasMore()) {
iter.GetNext()->Invalidate();
}
}
void
PluginModuleParent::AddToRefreshTimer(PluginInstanceParent *aInstance) {
if (mCATimerTargets.Contains(aInstance)) {
@@ -898,8 +915,17 @@ PluginModuleParent::AddToRefreshTimer(PluginInstanceParent *aInstance) {
mCATimerTargets.AppendElement(aInstance);
if (mCATimerTargets.Length() == 1) {
mCATimer.Start(base::TimeDelta::FromMilliseconds(DEFAULT_REFRESH_MS),
this, &PluginModuleParent::CAUpdate);
if (!mCATimer) {
nsresult rv;
nsCOMPtr<nsITimer> xpcomTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
NS_WARNING("Could not create Core Animation timer for plugin.");
return;
}
mCATimer = xpcomTimer;
}
mCATimer->InitWithFuncCallback(CAUpdate, &mCATimerTargets, DEFAULT_REFRESH_MS,
nsITimer::TYPE_REPEATING_SLACK);
}
}
@@ -907,15 +933,7 @@ void
PluginModuleParent::RemoveFromRefreshTimer(PluginInstanceParent *aInstance) {
PRBool visibleRemoved = mCATimerTargets.RemoveElement(aInstance);
if (visibleRemoved && mCATimerTargets.IsEmpty()) {
mCATimer.Stop();
}
}
void
PluginModuleParent::CAUpdate() {
nsTObserverArray<PluginInstanceParent*>::ForwardIterator iter(mCATimerTargets);
while (iter.HasMore()) {
iter.GetNext()->Invalidate();
mCATimer->Cancel();
}
}
#endif