Bug 752643 - Make CompositorParent eglSurface setup available for non-android environment. r=ajuma

This commit is contained in:
Oleg Romashin 2012-05-08 12:40:41 -07:00
Родитель e08a350b0d
Коммит 66a8a0359f
3 изменённых файлов: 34 добавлений и 12 удалений

Просмотреть файл

@ -57,7 +57,9 @@ using base::Thread;
namespace mozilla {
namespace layers {
CompositorParent::CompositorParent(nsIWidget* aWidget, MessageLoop* aMsgLoop, PlatformThreadId aThreadID)
CompositorParent::CompositorParent(nsIWidget* aWidget, MessageLoop* aMsgLoop,
PlatformThreadId aThreadID, bool aRenderToEGLSurface,
int aSurfaceWidth, int aSurfaceHeight)
: mWidget(aWidget)
, mCurrentCompositeTask(NULL)
, mPaused(false)
@ -67,6 +69,8 @@ CompositorParent::CompositorParent(nsIWidget* aWidget, MessageLoop* aMsgLoop, Pl
, mLayersUpdated(false)
, mCompositorLoop(aMsgLoop)
, mThreadID(aThreadID)
, mRenderToEGLSurface(aRenderToEGLSurface)
, mEGLSurfaceSize(aSurfaceWidth, aSurfaceHeight)
{
MOZ_COUNT_CTOR(CompositorParent);
}
@ -163,10 +167,20 @@ CompositorParent::ResumeComposition()
#endif
}
void
CompositorParent::SetEGLSurfaceSize(int width, int height)
{
NS_ASSERTION(mRenderToEGLSurface, "Compositor created without RenderToEGLSurface ar provided");
mEGLSurfaceSize.SizeTo(width, height);
if (mLayerManager) {
static_cast<LayerManagerOGL*>(mLayerManager.get())->SetSurfaceSize(mEGLSurfaceSize.width, mEGLSurfaceSize.height);
}
}
void
CompositorParent::ResumeCompositionAndResize(int width, int height)
{
static_cast<LayerManagerOGL*>(mLayerManager.get())->SetSurfaceSize(width, height);
SetEGLSurfaceSize(width, height);
ResumeComposition();
}
@ -434,14 +448,9 @@ PLayersParent*
CompositorParent::AllocPLayers(const LayersBackend &backendType)
{
if (backendType == LayerManager::LAYERS_OPENGL) {
#ifdef MOZ_JAVA_COMPOSITOR
nsIntRect rect;
mWidget->GetBounds(rect);
nsRefPtr<LayerManagerOGL> layerManager =
new LayerManagerOGL(mWidget, rect.width, rect.height, true);
#else
nsRefPtr<LayerManagerOGL> layerManager = new LayerManagerOGL(mWidget);
#endif
nsRefPtr<LayerManagerOGL> layerManager;
layerManager =
new LayerManagerOGL(mWidget, mEGLSurfaceSize.width, mEGLSurfaceSize.height, mRenderToEGLSurface);
mWidget = NULL;
mLayerManager = layerManager;

Просмотреть файл

@ -86,7 +86,9 @@ class CompositorParent : public PCompositorParent,
{
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositorParent)
public:
CompositorParent(nsIWidget* aWidget, MessageLoop* aMsgLoop, PlatformThreadId aThreadID);
CompositorParent(nsIWidget* aWidget, MessageLoop* aMsgLoop,
PlatformThreadId aThreadID, bool aRenderToEGLSurface = false,
int aSurfaceWidth = -1, int aSurfaceHeight = -1);
virtual ~CompositorParent();
@ -119,6 +121,7 @@ protected:
virtual void SetPageSize(float aZoom, float aPageWidth, float aPageHeight, float aCssPageWidth, float aCssPageHeight);
virtual void SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated,
nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY);
void SetEGLSurfaceSize(int width, int height);
private:
void PauseComposition();
@ -164,6 +167,8 @@ private:
MessageLoop* mCompositorLoop;
PlatformThreadId mThreadID;
bool mRenderToEGLSurface;
nsIntSize mEGLSurfaceSize;
DISALLOW_EVIL_CONSTRUCTORS(CompositorParent);
};

Просмотреть файл

@ -874,7 +874,15 @@ void nsBaseWidget::CreateCompositor()
{
mCompositorThread = new Thread("CompositorThread");
if (mCompositorThread->Start()) {
mCompositorParent = new CompositorParent(this, mCompositorThread->message_loop(), mCompositorThread->thread_id());
bool renderToEGLSurface = false;
#ifdef MOZ_JAVA_COMPOSITOR
renderToEGLSurface = true;
#endif
nsIntRect rect;
GetBounds(rect);
mCompositorParent =
new CompositorParent(this, mCompositorThread->message_loop(), mCompositorThread->thread_id(),
renderToEGLSurface, rect.width, rect.height);
LayerManager* lm = CreateBasicLayerManager();
MessageLoop *childMessageLoop = mCompositorThread->message_loop();
mCompositorChild = new CompositorChild(lm);