зеркало из https://github.com/mozilla/pjs.git
Bug 748209 - Allow compositorParent be created in custom Thread. r=ajuma
This commit is contained in:
Родитель
a95bd97711
Коммит
af4843bee4
|
@ -56,17 +56,30 @@ using base::Thread;
|
|||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
CompositorParent::CompositorParent(nsIWidget* aWidget, base::Thread* aCompositorThread)
|
||||
: mCompositorThread(aCompositorThread)
|
||||
, mWidget(aWidget)
|
||||
CompositorParent::CompositorParent(nsIWidget* aWidget, MessageLoop* aMsgLoop, PlatformThreadId aThreadID)
|
||||
: mWidget(aWidget)
|
||||
, mCurrentCompositeTask(NULL)
|
||||
, mPaused(false)
|
||||
, mIsFirstPaint(false)
|
||||
, mLayersUpdated(false)
|
||||
, mCompositorLoop(aMsgLoop)
|
||||
, mThreadID(aThreadID)
|
||||
{
|
||||
MOZ_COUNT_CTOR(CompositorParent);
|
||||
}
|
||||
|
||||
MessageLoop*
|
||||
CompositorParent::CompositorLoop()
|
||||
{
|
||||
return mCompositorLoop;
|
||||
}
|
||||
|
||||
PlatformThreadId
|
||||
CompositorParent::CompositorThreadID()
|
||||
{
|
||||
return mThreadID;
|
||||
}
|
||||
|
||||
CompositorParent::~CompositorParent()
|
||||
{
|
||||
MOZ_COUNT_DTOR(CompositorParent);
|
||||
|
@ -118,13 +131,13 @@ void
|
|||
CompositorParent::ScheduleRenderOnCompositorThread()
|
||||
{
|
||||
CancelableTask *renderTask = NewRunnableMethod(this, &CompositorParent::ScheduleComposition);
|
||||
mCompositorThread->message_loop()->PostTask(FROM_HERE, renderTask);
|
||||
CompositorLoop()->PostTask(FROM_HERE, renderTask);
|
||||
}
|
||||
|
||||
void
|
||||
CompositorParent::PauseComposition()
|
||||
{
|
||||
NS_ABORT_IF_FALSE(mCompositorThread->thread_id() == PlatformThread::CurrentId(),
|
||||
NS_ABORT_IF_FALSE(CompositorThreadID() == PlatformThread::CurrentId(),
|
||||
"PauseComposition() can only be called on the compositor thread");
|
||||
if (!mPaused) {
|
||||
mPaused = true;
|
||||
|
@ -138,7 +151,7 @@ CompositorParent::PauseComposition()
|
|||
void
|
||||
CompositorParent::ResumeComposition()
|
||||
{
|
||||
NS_ABORT_IF_FALSE(mCompositorThread->thread_id() == PlatformThread::CurrentId(),
|
||||
NS_ABORT_IF_FALSE(CompositorThreadID() == PlatformThread::CurrentId(),
|
||||
"ResumeComposition() can only be called on the compositor thread");
|
||||
mPaused = false;
|
||||
|
||||
|
@ -159,7 +172,7 @@ CompositorParent::SchedulePauseOnCompositorThread()
|
|||
{
|
||||
CancelableTask *pauseTask = NewRunnableMethod(this,
|
||||
&CompositorParent::PauseComposition);
|
||||
mCompositorThread->message_loop()->PostTask(FROM_HERE, pauseTask);
|
||||
CompositorLoop()->PostTask(FROM_HERE, pauseTask);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -167,7 +180,7 @@ CompositorParent::ScheduleResumeOnCompositorThread(int width, int height)
|
|||
{
|
||||
CancelableTask *resumeTask =
|
||||
NewRunnableMethod(this, &CompositorParent::ResumeCompositionAndResize, width, height);
|
||||
mCompositorThread->message_loop()->PostTask(FROM_HERE, resumeTask);
|
||||
CompositorLoop()->PostTask(FROM_HERE, resumeTask);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -211,7 +224,7 @@ CompositorParent::SetTransformation(float aScale, nsIntPoint aScrollOffset)
|
|||
void
|
||||
CompositorParent::Composite()
|
||||
{
|
||||
NS_ABORT_IF_FALSE(mCompositorThread->thread_id() == PlatformThread::CurrentId(),
|
||||
NS_ABORT_IF_FALSE(CompositorThreadID() == PlatformThread::CurrentId(),
|
||||
"Composite can only be called on the compositor thread");
|
||||
mCurrentCompositeTask = NULL;
|
||||
|
||||
|
|
|
@ -56,10 +56,6 @@
|
|||
|
||||
class nsIWidget;
|
||||
|
||||
namespace base {
|
||||
class Thread;
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
|
@ -90,7 +86,8 @@ class CompositorParent : public PCompositorParent,
|
|||
{
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositorParent)
|
||||
public:
|
||||
CompositorParent(nsIWidget* aWidget, base::Thread* aCompositorThread);
|
||||
CompositorParent(nsIWidget* aWidget, MessageLoop* aMsgLoop, PlatformThreadId aThreadID);
|
||||
|
||||
virtual ~CompositorParent();
|
||||
|
||||
virtual bool RecvWillStop() MOZ_OVERRIDE;
|
||||
|
@ -124,6 +121,9 @@ private:
|
|||
void ScheduleComposition();
|
||||
void TransformShadowTree();
|
||||
|
||||
inline MessageLoop* CompositorLoop();
|
||||
inline PlatformThreadId CompositorThreadID();
|
||||
|
||||
// Platform specific functions
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
/**
|
||||
|
@ -134,7 +134,6 @@ private:
|
|||
#endif
|
||||
|
||||
nsRefPtr<LayerManager> mLayerManager;
|
||||
base::Thread* mCompositorThread;
|
||||
nsIWidget* mWidget;
|
||||
CancelableTask *mCurrentCompositeTask;
|
||||
TimeStamp mLastCompose;
|
||||
|
@ -159,6 +158,9 @@ private:
|
|||
// after a layers update has it set. It is cleared after that first composition.
|
||||
bool mLayersUpdated;
|
||||
|
||||
MessageLoop* mCompositorLoop;
|
||||
PlatformThreadId mThreadID;
|
||||
|
||||
DISALLOW_EVIL_CONSTRUCTORS(CompositorParent);
|
||||
};
|
||||
|
||||
|
|
|
@ -873,8 +873,8 @@ nsBaseWidget::GetShouldAccelerate()
|
|||
void nsBaseWidget::CreateCompositor()
|
||||
{
|
||||
mCompositorThread = new Thread("CompositorThread");
|
||||
mCompositorParent = new CompositorParent(this, mCompositorThread);
|
||||
if (mCompositorThread->Start()) {
|
||||
mCompositorParent = new CompositorParent(this, mCompositorThread->message_loop(), mCompositorThread->thread_id());
|
||||
LayerManager* lm = CreateBasicLayerManager();
|
||||
MessageLoop *childMessageLoop = mCompositorThread->message_loop();
|
||||
mCompositorChild = new CompositorChild(lm);
|
||||
|
|
Загрузка…
Ссылка в новой задаче