зеркало из https://github.com/mozilla/pjs.git
Bug 692759 - Fix Non-InvalidatingCoreAnimation refresh timer for async layers plugins. r=smichaud
--HG-- extra : rebase_source : 3017218abbe7897aa34b7a868cc63e49550246ce
This commit is contained in:
Родитель
57e093059d
Коммит
f8b3ddd376
|
@ -201,6 +201,9 @@ PluginInstanceChild::~PluginInstanceChild()
|
|||
if (mCGLayer) {
|
||||
PluginUtilsOSX::ReleaseCGLayer(mCGLayer);
|
||||
}
|
||||
if (mDrawingModel == NPDrawingModelCoreAnimation) {
|
||||
UnscheduleTimer(mCARefreshTimer);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -460,6 +463,22 @@ PluginInstanceChild::NPN_GetValue(NPNVariable aVar,
|
|||
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_COCOA
|
||||
#define DEFAULT_REFRESH_MS 20 // CoreAnimation: 50 FPS
|
||||
|
||||
void
|
||||
CAUpdate(NPP npp, uint32_t timerID) {
|
||||
static_cast<PluginInstanceChild*>(npp->ndata)->Invalidate();
|
||||
}
|
||||
|
||||
void
|
||||
PluginInstanceChild::Invalidate()
|
||||
{
|
||||
NPRect windowRect = {0, 0, mWindow.height, mWindow.width};
|
||||
|
||||
InvalidateRect(&windowRect);
|
||||
}
|
||||
#endif
|
||||
|
||||
NPError
|
||||
PluginInstanceChild::NPN_SetValue(NPPVariable aVar, void* aValue)
|
||||
|
@ -507,6 +526,10 @@ PluginInstanceChild::NPN_SetValue(NPPVariable aVar, void* aValue)
|
|||
return NPERR_GENERIC_ERROR;
|
||||
mDrawingModel = drawingModel;
|
||||
|
||||
if (drawingModel == NPDrawingModelCoreAnimation) {
|
||||
mCARefreshTimer = ScheduleTimer(DEFAULT_REFRESH_MS, true, CAUpdate);
|
||||
}
|
||||
|
||||
PLUGIN_LOG_DEBUG((" Plugin requested drawing model id #%i\n",
|
||||
mDrawingModel));
|
||||
|
||||
|
|
|
@ -236,6 +236,10 @@ public:
|
|||
|
||||
void InvalidateRect(NPRect* aInvalidRect);
|
||||
|
||||
#ifdef MOZ_WIDGET_COCOA
|
||||
void Invalidate();
|
||||
#endif // definied(MOZ_WIDGET_COCOA)
|
||||
|
||||
uint32_t ScheduleTimer(uint32_t interval, bool repeat, TimerFunc func);
|
||||
void UnscheduleTimer(uint32_t id);
|
||||
|
||||
|
@ -426,6 +430,9 @@ private:
|
|||
nsCARenderer mCARenderer;
|
||||
void *mCGLayer;
|
||||
|
||||
// Core Animation drawing model requires a refresh timer.
|
||||
uint32_t mCARefreshTimer;
|
||||
|
||||
public:
|
||||
const NPCocoaEvent* getCurrentEvent() {
|
||||
return mCurrentEvent;
|
||||
|
|
|
@ -96,7 +96,6 @@ PluginInstanceParent::PluginInstanceParent(PluginModuleParent* parent,
|
|||
, mPluginWndProc(NULL)
|
||||
, mNestedEventState(false)
|
||||
#endif // defined(XP_WIN)
|
||||
, mQuirks(0)
|
||||
#if defined(XP_MACOSX)
|
||||
, mShWidth(0)
|
||||
, mShHeight(0)
|
||||
|
@ -104,20 +103,6 @@ PluginInstanceParent::PluginInstanceParent(PluginModuleParent* parent,
|
|||
, mDrawingModel(NPDrawingModelCoreGraphics)
|
||||
#endif
|
||||
{
|
||||
InitQuirksModes(aMimeType);
|
||||
}
|
||||
|
||||
void
|
||||
PluginInstanceParent::InitQuirksModes(const nsCString& aMimeType)
|
||||
{
|
||||
#ifdef MOZ_WIDGET_COCOA
|
||||
NS_NAMED_LITERAL_CSTRING(flash, "application/x-shockwave-flash");
|
||||
// Flash sends us Invalidate events so we will use those
|
||||
// instead of the refresh timer.
|
||||
if (!FindInReadable(flash, aMimeType)) {
|
||||
mQuirks |= COREANIMATION_REFRESH_TIMER;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
PluginInstanceParent::~PluginInstanceParent()
|
||||
|
@ -135,9 +120,6 @@ PluginInstanceParent::~PluginInstanceParent()
|
|||
}
|
||||
if (mShColorSpace)
|
||||
::CGColorSpaceRelease(mShColorSpace);
|
||||
if (mDrawingModel == NPDrawingModelCoreAnimation) {
|
||||
mParent->RemoveFromRefreshTimer(this);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -394,10 +376,6 @@ PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginDrawingModel(
|
|||
mDrawingModel = drawingModel;
|
||||
*result = mNPNIface->setvalue(mNPP, NPPVpluginDrawingModel,
|
||||
(void*)NPDrawingModelCoreGraphics);
|
||||
if (drawingModel == NPDrawingModelCoreAnimation &&
|
||||
mQuirks & COREANIMATION_REFRESH_TIMER) {
|
||||
mParent->AddToRefreshTimer(this);
|
||||
}
|
||||
} else {
|
||||
mDrawingModel = drawingModel;
|
||||
*result = mNPNIface->setvalue(mNPP, NPPVpluginDrawingModel,
|
||||
|
@ -1863,12 +1841,3 @@ PluginInstanceParent::AnswerPluginFocusChange(const bool& gotFocus)
|
|||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_COCOA
|
||||
void
|
||||
PluginInstanceParent::Invalidate()
|
||||
{
|
||||
NPRect windowRect = {0, 0, mShHeight, mShWidth};
|
||||
RecvNPN_InvalidateRect(windowRect);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -279,10 +279,6 @@ public:
|
|||
virtual bool
|
||||
AnswerPluginFocusChange(const bool& gotFocus);
|
||||
|
||||
#ifdef MOZ_WIDGET_COCOA
|
||||
void Invalidate();
|
||||
#endif // definied(MOZ_WIDGET_COCOA)
|
||||
|
||||
nsresult AsyncSetWindow(NPWindow* window);
|
||||
nsresult GetImage(mozilla::layers::ImageContainer* aContainer, mozilla::layers::Image** aImage);
|
||||
nsresult GetImageSize(nsIntSize* aSize);
|
||||
|
@ -313,16 +309,6 @@ private:
|
|||
virtual bool
|
||||
DeallocPPluginBackgroundDestroyer(PPluginBackgroundDestroyerParent* aActor);
|
||||
|
||||
// Quirks mode support for various plugin mime types
|
||||
enum PluginQuirks {
|
||||
// OSX: Don't use the refresh timer for plug-ins
|
||||
// using this quirk. These plug-in most have another
|
||||
// way to refresh the window.
|
||||
COREANIMATION_REFRESH_TIMER = 1,
|
||||
};
|
||||
|
||||
void InitQuirksModes(const nsCString& aMimeType);
|
||||
|
||||
bool InternalGetValueForNPObject(NPNVariable aVariable,
|
||||
PPluginScriptableObjectParent** aValue,
|
||||
NPError* aResult);
|
||||
|
@ -332,7 +318,6 @@ private:
|
|||
NPP mNPP;
|
||||
const NPNetscapeFuncs* mNPNIface;
|
||||
NPWindowType mWindowType;
|
||||
int mQuirks;
|
||||
|
||||
nsDataHashtable<nsVoidPtrHashKey, PluginScriptableObjectParent*> mScriptableObjects;
|
||||
|
||||
|
|
|
@ -146,12 +146,6 @@ 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;
|
||||
|
@ -1171,52 +1165,6 @@ PluginModuleParent::RecvGetNativeCursorsSupported(bool* supported)
|
|||
#endif
|
||||
}
|
||||
|
||||
#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);
|
||||
#ifdef MOZ_WIDGET_COCOA
|
||||
while (iter.HasMore()) {
|
||||
iter.GetNext()->Invalidate();
|
||||
}
|
||||
#endif // MOZ_WIDGET_COCOA
|
||||
}
|
||||
|
||||
void
|
||||
PluginModuleParent::AddToRefreshTimer(PluginInstanceParent *aInstance) {
|
||||
if (mCATimerTargets.Contains(aInstance)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mCATimerTargets.AppendElement(aInstance);
|
||||
if (mCATimerTargets.Length() == 1) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PluginModuleParent::RemoveFromRefreshTimer(PluginInstanceParent *aInstance) {
|
||||
bool visibleRemoved = mCATimerTargets.RemoveElement(aInstance);
|
||||
if (visibleRemoved && mCATimerTargets.IsEmpty()) {
|
||||
mCATimer->Cancel();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bool
|
||||
PluginModuleParent::RecvNPN_SetException(PPluginScriptableObjectParent* aActor,
|
||||
const nsCString& aMessage)
|
||||
|
|
|
@ -61,8 +61,6 @@
|
|||
#include "nsDataHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsIFileStreams.h"
|
||||
#include "nsTObserverArray.h"
|
||||
#include "nsITimer.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -155,11 +153,6 @@ public:
|
|||
|
||||
void ProcessRemoteNativeEventsInRPCCall();
|
||||
|
||||
#ifdef OS_MACOSX
|
||||
void AddToRefreshTimer(PluginInstanceParent *aInstance);
|
||||
void RemoveFromRefreshTimer(PluginInstanceParent *aInstance);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
NS_OVERRIDE
|
||||
virtual mozilla::ipc::RPCChannel::RacyRPCPolicy
|
||||
|
@ -335,11 +328,6 @@ private:
|
|||
nsString mBrowserDumpID;
|
||||
nsString mHangID;
|
||||
|
||||
#ifdef OS_MACOSX
|
||||
nsCOMPtr<nsITimer> mCATimer;
|
||||
nsTObserverArray<PluginInstanceParent*> mCATimerTargets;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_X11
|
||||
// Dup of plugin's X socket, used to scope its resources to this
|
||||
// object instead of the plugin process's lifetime
|
||||
|
|
Загрузка…
Ссылка в новой задаче