зеркало из https://github.com/mozilla/gecko-dev.git
Back out bug 1328602 (5 csets) for build bustage and test failures. r=bustage
This commit is contained in:
Родитель
e90faa1dbd
Коммит
e747fadcd2
|
@ -1,197 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "RenderThread.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "mozilla/layers/RendererOGL.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
static StaticRefPtr<RenderThread> sRenderThread;
|
||||
|
||||
RenderThread::RenderThread(base::Thread* aThread)
|
||||
: mThread(aThread)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RenderThread::~RenderThread()
|
||||
{
|
||||
delete mThread;
|
||||
}
|
||||
|
||||
// statuc
|
||||
RenderThread*
|
||||
RenderThread::Get()
|
||||
{
|
||||
return sRenderThread;
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
RenderThread::Start()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!sRenderThread);
|
||||
|
||||
base::Thread* thread = new base::Thread("Compositor");
|
||||
|
||||
base::Thread::Options options;
|
||||
// TODO(nical): The compositor thread has a bunch of specific options, see
|
||||
// which ones make sense here.
|
||||
if (!thread->StartWithOptions(options)) {
|
||||
delete thread;
|
||||
return;
|
||||
}
|
||||
|
||||
sRenderThread = new RenderThread(thread);
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
RenderThread::ShutDown()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(sRenderThread);
|
||||
|
||||
// TODO(nical): sync with the render thread
|
||||
|
||||
sRenderThread = nullptr;
|
||||
}
|
||||
|
||||
// static
|
||||
MessageLoop*
|
||||
RenderThread::Loop()
|
||||
{
|
||||
return sRenderThread ? sRenderThread->mThread->message_loop() : nullptr;
|
||||
}
|
||||
|
||||
// static
|
||||
bool
|
||||
RenderThread::IsInRenderThread()
|
||||
{
|
||||
return sRenderThread && sRenderThread->mThread->thread_id() == PlatformThread::CurrentId();
|
||||
}
|
||||
|
||||
void
|
||||
RenderThread::AddRenderer(wr::WindowId aWindowId, UniquePtr<RendererOGL> aRenderer)
|
||||
{
|
||||
mRenderers[aWindowId] = Move(aRenderer);
|
||||
}
|
||||
|
||||
void
|
||||
RenderThread::RemoveRenderer(wr::WindowId aWindowId)
|
||||
{
|
||||
mRenderers.erase(aWindowId);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RenderThread::NewFrameReady(wr::WindowId aWindowId)
|
||||
{
|
||||
if (!IsInRenderThread()) {
|
||||
Loop()->PostTask(NewRunnableMethod<wr::WindowId>(
|
||||
this, &RenderThread::NewFrameReady, aWindowId
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateAndRender(aWindowId);
|
||||
}
|
||||
|
||||
void
|
||||
RenderThread::NewScrollFrameReady(wr::WindowId aWindowId, bool aCompositeNeeded)
|
||||
{
|
||||
if (!IsInRenderThread()) {
|
||||
Loop()->PostTask(NewRunnableMethod<wr::WindowId, bool>(
|
||||
this, &RenderThread::NewScrollFrameReady, aWindowId, aCompositeNeeded
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateAndRender(aWindowId);
|
||||
}
|
||||
|
||||
void
|
||||
RenderThread::PipelineSizeChanged(wr::WindowId aWindowId, uint64_t aPipelineId, float aWidth, float aHeight)
|
||||
{
|
||||
if (!IsInRenderThread()) {
|
||||
Loop()->PostTask(NewRunnableMethod<wr::WindowId, uint64_t, float, float>(
|
||||
this, &RenderThread::PipelineSizeChanged,
|
||||
aWindowId, aPipelineId, aWidth, aHeight
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateAndRender(aWindowId);
|
||||
}
|
||||
|
||||
void
|
||||
RenderThread::RunEvent(wr::WindowId aWindowId, UniquePtr<RendererEvent> aEvent)
|
||||
{
|
||||
if (!IsInRenderThread()) {
|
||||
Loop()->PostTask(NewRunnableMethod<wr::WindowId, UniquePtr<RendererEvent>&&>(
|
||||
this, &RenderThread::RunEvent,
|
||||
aWindowId, Move(aEvent)
|
||||
));
|
||||
}
|
||||
|
||||
aEvent->Run(*this, aWindowId);
|
||||
aEvent = nullptr;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RenderThread::UpdateAndRender(wr::WindowId aWindowId)
|
||||
{
|
||||
auto it = mRenderers.find(aWindowId);
|
||||
MOZ_ASSERT(it != mRenderers.end());
|
||||
if (it == mRenderers.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto& renderer = it->second;
|
||||
|
||||
auto transactionId = 0; // TODO!
|
||||
|
||||
renderer->Update();
|
||||
renderer->Render(transactionId);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
extern "C" {
|
||||
|
||||
void wr_notifier_new_frame_ready(uint64_t aWindowId)
|
||||
{
|
||||
mozilla::layers::RenderThread::Get()->NewFrameReady(mozilla::wr::WindowId(aWindowId));
|
||||
}
|
||||
|
||||
void wr_notifier_new_scroll_frame_ready(uint64_t aWindowId, bool aCompositeNeeded)
|
||||
{
|
||||
mozilla::layers::RenderThread::Get()->NewScrollFrameReady(mozilla::wr::WindowId(aWindowId),
|
||||
aCompositeNeeded);
|
||||
}
|
||||
|
||||
void wr_notifier_pipeline_size_changed(uint64_t aWindowId,
|
||||
uint64_t aPipelineId,
|
||||
float aWidth,
|
||||
float aHeight)
|
||||
{
|
||||
mozilla::layers::RenderThread::Get()->PipelineSizeChanged(mozilla::wr::WindowId(aWindowId),
|
||||
aPipelineId, aWidth, aHeight);
|
||||
}
|
||||
|
||||
void wr_notifier_external_event(uint64_t aWindowId, size_t aRawEvent)
|
||||
{
|
||||
mozilla::UniquePtr<mozilla::layers::RendererEvent> evt(
|
||||
reinterpret_cast<mozilla::layers::RendererEvent*>(aRawEvent));
|
||||
mozilla::layers::RenderThread::Get()->RunEvent(mozilla::wr::WindowId(aWindowId),
|
||||
mozilla::Move(evt));
|
||||
}
|
||||
|
||||
} // extern C
|
|
@ -1,110 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set sw=2 sts=2 ts=8 et tw=99 : */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef MOZILLA_LAYERS_RENDERTHREAD_H
|
||||
#define MOZILLA_LAYERS_RENDERTHREAD_H
|
||||
|
||||
#include "base/basictypes.h" // for DISALLOW_EVIL_CONSTRUCTORS
|
||||
#include "base/platform_thread.h" // for PlatformThreadId
|
||||
#include "base/thread.h" // for Thread
|
||||
#include "base/message_loop.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "ThreadSafeRefcountingWithMainThreadDestruction.h"
|
||||
#include "mozilla/gfx/webrender.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
class RendererOGL;
|
||||
class RenderThread;
|
||||
|
||||
/// Base class for an event that can bes cheduled to run on the render thread.
|
||||
///
|
||||
/// The event can be passed through the same channels as regular WebRender messages
|
||||
/// to preserve ordering.
|
||||
class RendererEvent
|
||||
{
|
||||
public:
|
||||
virtual ~RendererEvent() {}
|
||||
virtual void Run(RenderThread& aRenderThread, wr::WindowId aWindow);
|
||||
};
|
||||
|
||||
/// The render thread is where WebRender issues all of its GPU work, and as much
|
||||
/// as possible this thread should only serve this purpose.
|
||||
///
|
||||
/// The render thread owns the different RendererOGLs (one per window) and implements
|
||||
/// the RenderNotifier api exposed by the WebRender bindings.
|
||||
///
|
||||
/// We should generally avoid posting tasks to the render thhread's event loop directly
|
||||
/// and instead use the RendererEvent mechanism which avoids races between the events
|
||||
/// and WebRender's own messages.
|
||||
///
|
||||
/// The GL context(s) should be created and used on this thread only.
|
||||
/// XXX - I've tried to organize code so that we can potentially avoid making
|
||||
/// this a singleton since this bad habbit has a tendency to bite us later, but
|
||||
/// I haven't gotten all the way there either in order to focus on the more
|
||||
/// important pieces first. So we are a bit in-between (this is totally a singleton
|
||||
/// but in some places we pretend it's not). Hopefully we can evolve this in a way
|
||||
/// that keeps the door open to removing the singleton bits.
|
||||
class RenderThread final
|
||||
{
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION(RenderThread)
|
||||
|
||||
public:
|
||||
/// Can be called from any thread.
|
||||
static RenderThread* Get();
|
||||
|
||||
static void Start();
|
||||
|
||||
static void ShutDown();
|
||||
|
||||
/// Can be called from any thread.
|
||||
/// In most cases it is best to use RendererEvents through WebRender's api instead
|
||||
/// of scheduling directly to this message loop (so as to preserve the ordering
|
||||
/// of the messages).
|
||||
static MessageLoop* Loop();
|
||||
|
||||
/// Can be called from any thread.
|
||||
static bool IsInRenderThread();
|
||||
|
||||
/// Can only be called from the render thread.
|
||||
void AddRenderer(wr::WindowId aWindowId, UniquePtr<RendererOGL> aRenderer);
|
||||
|
||||
/// Can only be called from the render thread.
|
||||
void RemoveRenderer(wr::WindowId aWindowId);
|
||||
|
||||
// RenderNotifier implementation
|
||||
|
||||
/// Automatically forwarded to the render thread.
|
||||
void NewFrameReady(wr::WindowId aWindowId);
|
||||
|
||||
/// Automatically forwarded to the render thread.
|
||||
void NewScrollFrameReady(wr::WindowId aWindowId, bool aCompositeNeeded);
|
||||
|
||||
/// Automatically forwarded to the render thread.
|
||||
void PipelineSizeChanged(wr::WindowId aWindowId, uint64_t aPipelineId, float aWidth, float aHeight);
|
||||
|
||||
/// Automatically forwarded to the render thread.
|
||||
void RunEvent(wr::WindowId aWindowId, UniquePtr<RendererEvent> aCallBack);
|
||||
|
||||
private:
|
||||
RenderThread(base::Thread* aThread);
|
||||
|
||||
~RenderThread();
|
||||
|
||||
/// Can only be called from the render thread.
|
||||
void UpdateAndRender(wr::WindowId aWindowId);
|
||||
|
||||
base::Thread* const mThread;
|
||||
|
||||
std::map<wr::WindowId, UniquePtr<RendererOGL>> mRenderers;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
#endif
|
|
@ -192,11 +192,9 @@ EXPORTS.mozilla.layers += [
|
|||
'opengl/CompositorOGL.h',
|
||||
'opengl/MacIOSurfaceTextureClientOGL.h',
|
||||
'opengl/MacIOSurfaceTextureHostOGL.h',
|
||||
'opengl/RendererOGL.h',
|
||||
'opengl/TextureClientOGL.h',
|
||||
'opengl/TextureHostOGL.h',
|
||||
'PersistentBufferProvider.h',
|
||||
'RenderThread.h',
|
||||
'RenderTrace.h',
|
||||
'TextureWrapperImage.h',
|
||||
'TransactionIdAllocator.h',
|
||||
|
@ -367,13 +365,11 @@ UNIFIED_SOURCES += [
|
|||
'opengl/CompositorOGL.cpp',
|
||||
'opengl/GLBlitTextureImageHelper.cpp',
|
||||
'opengl/OGLShaderProgram.cpp',
|
||||
'opengl/RendererOGL.cpp',
|
||||
'opengl/TextureClientOGL.cpp',
|
||||
'opengl/TextureHostOGL.cpp',
|
||||
'opengl/TexturePoolOGL.cpp',
|
||||
'protobuf/LayerScopePacket.pb.cc',
|
||||
'ReadbackProcessor.cpp',
|
||||
'RenderThread.cpp',
|
||||
'RenderTrace.cpp',
|
||||
'RotatedBuffer.cpp',
|
||||
'ShareableCanvasLayer.cpp',
|
||||
|
|
|
@ -1,131 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "RendererOGL.h"
|
||||
#include "GLContext.h"
|
||||
#include "GLContextProvider.h"
|
||||
#include "mozilla/gfx/Logging.h"
|
||||
#include "mozilla/layers/WebRenderBridgeParent.h"
|
||||
#include "mozilla/layers/CompositorThread.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
// static
|
||||
RendererOGL*
|
||||
RendererOGL::Create(already_AddRefed<RenderThread> aThread,
|
||||
already_AddRefed<widget::CompositorWidget> aWidget,
|
||||
WrRenderer* aWrRenderer,
|
||||
wr::WindowId aWindowId,
|
||||
WebRenderBridgeParent* aBridge)
|
||||
{
|
||||
RefPtr<widget::CompositorWidget> widget = aWidget;
|
||||
RefPtr<RenderThread> thread = aThread;
|
||||
|
||||
MOZ_ASSERT(widget);
|
||||
MOZ_ASSERT(thread);
|
||||
MOZ_ASSERT(aWrRenderer);
|
||||
MOZ_ASSERT(RenderThread::IsInRenderThread());
|
||||
|
||||
if (!widget || !thread) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<gl::GLContext> gl = gl::GLContextProvider::CreateForCompositorWidget(widget, true);
|
||||
if (!gl) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!gl->MakeCurrent()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new RendererOGL(thread.forget(),
|
||||
gl.forget(),
|
||||
widget.forget(),
|
||||
aWindowId,
|
||||
aWrRenderer,
|
||||
aBridge);
|
||||
}
|
||||
|
||||
RendererOGL::RendererOGL(already_AddRefed<RenderThread> aThread,
|
||||
already_AddRefed<gl::GLContext> aGL,
|
||||
already_AddRefed<widget::CompositorWidget> aWidget,
|
||||
wr::WindowId aWindowId,
|
||||
WrRenderer* aWrRenderer,
|
||||
WebRenderBridgeParent* aBridge)
|
||||
: mThread(aThread)
|
||||
, mGL(aGL)
|
||||
, mWidget(aWidget)
|
||||
, mWrRenderer(aWrRenderer)
|
||||
, mBridge(aBridge)
|
||||
, mWindowId(aWindowId)
|
||||
{
|
||||
}
|
||||
|
||||
RendererOGL::~RendererOGL()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
RendererOGL::Update()
|
||||
{
|
||||
wr_renderer_update(mWrRenderer);
|
||||
}
|
||||
|
||||
bool
|
||||
RendererOGL::Render(uint64_t aTransactionId)
|
||||
{
|
||||
// TODO: WebRender has the notion of epoch and gecko has transaction ids.
|
||||
// They mostly mean the same thing but I'm not sure they are produced the same
|
||||
// way. We need to merge the two or have a way to associate transaction ids with
|
||||
// epochs to wire everything up properly.
|
||||
|
||||
TimeStamp start = TimeStamp::Now();
|
||||
|
||||
if (!mGL->MakeCurrent()) {
|
||||
gfxCriticalNote << "Failed to make render context current, can't draw.";
|
||||
return false;
|
||||
}
|
||||
|
||||
mozilla::widget::WidgetRenderingContext widgetContext;
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
widgetContext.mGL = mGL;
|
||||
// TODO: we don't have a notion of compositor here.
|
||||
//#elif defined(MOZ_WIDGET_ANDROID)
|
||||
// widgetContext.mCompositor = mCompositor;
|
||||
#endif
|
||||
|
||||
if (!mWidget->PreRender(&widgetContext)) {
|
||||
return false;
|
||||
}
|
||||
// XXX set clear color if MOZ_WIDGET_ANDROID is defined.
|
||||
// XXX pass the actual render bounds instead of an empty rect.
|
||||
mWidget->DrawWindowUnderlay(&widgetContext, LayoutDeviceIntRect());
|
||||
|
||||
auto size = mWidget->GetClientSize();
|
||||
wr_renderer_render(mWrRenderer, size.width, size.height);
|
||||
|
||||
mGL->SwapBuffers();
|
||||
mWidget->DrawWindowOverlay(&widgetContext, LayoutDeviceIntRect());
|
||||
mWidget->PostRender(&widgetContext);
|
||||
|
||||
// TODO: Flush pending actions such as texture deletions/unlocks.
|
||||
|
||||
TimeStamp end = TimeStamp::Now();
|
||||
|
||||
CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod<uint64_t, TimeStamp, TimeStamp>(
|
||||
mBridge,
|
||||
&WebRenderBridgeParent::DidComposite,
|
||||
aTransactionId, start, end
|
||||
));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set sw=2 sts=2 ts=8 et tw=99 : */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef MOZILLA_LAYERS_RENDEREROGL_H
|
||||
#define MOZILLA_LAYERS_RENDEREROGL_H
|
||||
|
||||
#include "mozilla/layers/RenderThread.h"
|
||||
#include "mozilla/gfx/webrender.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace gfx {
|
||||
class DrawTarget;
|
||||
}
|
||||
|
||||
namespace gl {
|
||||
class GLContext;
|
||||
}
|
||||
|
||||
namespace widget {
|
||||
class CompositorWidget;
|
||||
}
|
||||
|
||||
namespace layers {
|
||||
|
||||
class WebRenderBridgeParent;
|
||||
|
||||
/// Owns the WebRender renderer and GL context.
|
||||
///
|
||||
/// There is one renderer per window, all owned by the render thread.
|
||||
/// This class is a similar abstraction to CompositorOGL except that it is used
|
||||
/// on the render thread instead of the compositor thread.
|
||||
class RendererOGL
|
||||
{
|
||||
public:
|
||||
|
||||
/// Render thread only.
|
||||
static RendererOGL* Create(already_AddRefed<RenderThread> aThread,
|
||||
already_AddRefed<widget::CompositorWidget> aWidget,
|
||||
WrRenderer* aWrRenderer,
|
||||
wr::WindowId aWindowId,
|
||||
WebRenderBridgeParent* aBridge);
|
||||
|
||||
/// Render thread only.
|
||||
void Update();
|
||||
|
||||
/// Render thread only.
|
||||
bool Render(uint64_t aTransactionId);
|
||||
|
||||
/// Render thread only.
|
||||
bool RenderToTarget(gfx::DrawTarget& aTarget);
|
||||
|
||||
/// Render thread only.
|
||||
~RendererOGL();
|
||||
|
||||
protected:
|
||||
RendererOGL(already_AddRefed<RenderThread> aThread,
|
||||
already_AddRefed<gl::GLContext> aGL,
|
||||
already_AddRefed<widget::CompositorWidget>,
|
||||
wr::WindowId aWindowId,
|
||||
WrRenderer* aWrRenderer,
|
||||
WebRenderBridgeParent* aBridge);
|
||||
|
||||
RefPtr<RenderThread> mThread;
|
||||
RefPtr<gl::GLContext> mGL;
|
||||
RefPtr<widget::CompositorWidget> mWidget;
|
||||
WrRenderer* mWrRenderer;
|
||||
WebRenderBridgeParent* mBridge;
|
||||
wr::WindowId mWindowId;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -15,7 +15,6 @@
|
|||
#include "mozilla/layers/CompositorVsyncScheduler.h"
|
||||
#include "mozilla/layers/ImageBridgeParent.h"
|
||||
#include "mozilla/layers/ImageDataSerializer.h"
|
||||
#include "mozilla/layers/RenderThread.h"
|
||||
#include "mozilla/layers/TextureHost.h"
|
||||
#include "mozilla/layers/WebRenderCompositorOGL.h"
|
||||
#include "mozilla/widget/CompositorWidget.h"
|
||||
|
@ -25,11 +24,6 @@ bool is_in_compositor_thread()
|
|||
return mozilla::layers::CompositorThreadHolder::IsInCompositorThread();
|
||||
}
|
||||
|
||||
bool is_in_render_thread()
|
||||
{
|
||||
return mozilla::layers::RenderThread::IsInRenderThread();
|
||||
}
|
||||
|
||||
void* get_proc_address_from_glcontext(void* glcontext_ptr, const char* procname)
|
||||
{
|
||||
MOZ_ASSERT(glcontext_ptr);
|
||||
|
@ -517,12 +511,6 @@ WebRenderBridgeParent::CompositeToTarget(gfx::DrawTarget* aTarget, const gfx::In
|
|||
mCompositor->FlushPendingNotifyNotUsed();
|
||||
}
|
||||
|
||||
void
|
||||
WebRenderBridgeParent::DidComposite(uint64_t aTransactionId, TimeStamp aStart, TimeStamp aEnd)
|
||||
{
|
||||
mCompositorBridge->NotifyDidComposite(aTransactionId, aStart, aEnd);
|
||||
}
|
||||
|
||||
WebRenderBridgeParent::~WebRenderBridgeParent()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -106,8 +106,6 @@ public:
|
|||
void SendPendingAsyncMessages() override;
|
||||
void SetAboutToSendAsyncMessages() override;
|
||||
|
||||
void DidComposite(uint64_t aTransactionId, TimeStamp aStart, TimeStamp aEnd);
|
||||
|
||||
private:
|
||||
virtual ~WebRenderBridgeParent();
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "mozilla/layers/CompositorThread.h"
|
||||
#include "mozilla/layers/ImageBridgeChild.h"
|
||||
#include "mozilla/layers/ISurfaceAllocator.h" // for GfxMemoryImageReporter
|
||||
#include "mozilla/layers/RenderThread.h"
|
||||
#include "mozilla/gfx/gfxVars.h"
|
||||
#include "mozilla/gfx/GPUProcessManager.h"
|
||||
#include "mozilla/gfx/GraphicsMessages.h"
|
||||
|
@ -940,9 +939,6 @@ gfxPlatform::InitLayersIPC()
|
|||
|
||||
if (XRE_IsParentProcess())
|
||||
{
|
||||
if (gfxPrefs::WebRenderEnabled()) {
|
||||
layers::RenderThread::Start();
|
||||
}
|
||||
layers::CompositorThreadHolder::Start();
|
||||
}
|
||||
}
|
||||
|
@ -969,7 +965,6 @@ gfxPlatform::ShutdownLayersIPC()
|
|||
|
||||
// This has to happen after shutting down the child protocols.
|
||||
layers::CompositorThreadHolder::Shutdown();
|
||||
layers::RenderThread::ShutDown();
|
||||
} else {
|
||||
// TODO: There are other kind of processes and we should make sure gfx
|
||||
// stuff is either not created there or shut down properly.
|
||||
|
|
|
@ -17,9 +17,6 @@ use webrender::renderer::{ExternalImage, ExternalImageHandler, ExternalImageSour
|
|||
use std::sync::{Arc, Mutex, Condvar};
|
||||
extern crate webrender_traits;
|
||||
|
||||
fn pipeline_id_to_u64(id: PipelineId) -> u64 { (id.0 as u64) << 32 + id.1 as u64 }
|
||||
fn u64_to_pipeline_id(id: u64) -> PipelineId { PipelineId((id >> 32) as u32, id as u32) }
|
||||
|
||||
fn get_proc_address(glcontext_ptr: *mut c_void, name: &str) -> *const c_void{
|
||||
|
||||
extern {
|
||||
|
@ -42,169 +39,8 @@ fn get_proc_address(glcontext_ptr: *mut c_void, name: &str) -> *const c_void{
|
|||
|
||||
extern {
|
||||
fn is_in_compositor_thread() -> bool;
|
||||
fn is_in_render_thread() -> bool;
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn wr_renderer_update(renderer: &mut Renderer) {
|
||||
renderer.update();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn wr_renderer_render(renderer: &mut Renderer, width: u32, height: u32) {
|
||||
renderer.render(DeviceUintSize::new(width, height));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn wr_renderer_set_profiler_enabled(renderer: &mut Renderer, enabled: bool) {
|
||||
renderer.set_profiler_enabled(enabled);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn wr_renderer_current_epoch(renderer: &mut Renderer,
|
||||
pipeline_id: PipelineId,
|
||||
out_epoch: &mut Epoch) -> bool {
|
||||
if let Some(epoch) = renderer.current_epoch(pipeline_id) {
|
||||
*out_epoch = epoch;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern fn wr_renderer_delete(renderer: *mut Renderer) {
|
||||
Box::from_raw(renderer);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern fn wr_api_delete(api: *mut webrender_traits::RenderApi) {
|
||||
Box::from_raw(api);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn wr_window_new(window_id: u64,
|
||||
enable_profiler: bool,
|
||||
out_api: &mut *mut webrender_traits::RenderApi,
|
||||
out_renderer: &mut *mut Renderer) {
|
||||
assert!(unsafe { is_in_compositor_thread() });
|
||||
|
||||
let opts = RendererOptions {
|
||||
device_pixel_ratio: 1.0,
|
||||
resource_override_path: None,
|
||||
enable_aa: false,
|
||||
enable_subpixel_aa: false,
|
||||
enable_msaa: false,
|
||||
enable_profiler: enable_profiler,
|
||||
enable_recording: false,
|
||||
enable_scrollbars: false,
|
||||
precache_shaders: false,
|
||||
renderer_kind: RendererKind::Native,
|
||||
debug: false,
|
||||
clear_framebuffer: true,
|
||||
clear_empty_tiles: false,
|
||||
clear_color: ColorF::new(1.0, 1.0, 1.0, 1.0),
|
||||
};
|
||||
|
||||
let (renderer, sender) = Renderer::new(opts);
|
||||
renderer.set_render_notifier(Box::new(CppNotifier { window_id: window_id }));
|
||||
|
||||
*out_api = Box::into_raw(Box::new(sender.create_api()));
|
||||
*out_renderer = Box::into_raw(Box::new(renderer));
|
||||
}
|
||||
|
||||
// Call MakeCurrent before this.
|
||||
#[no_mangle]
|
||||
pub extern fn wr_gl_init(gl_context: *mut c_void) {
|
||||
assert!(unsafe { is_in_render_thread() });
|
||||
|
||||
gl::load_with(|symbol| get_proc_address(gl_context, symbol));
|
||||
gl::clear_color(0.3, 0.0, 0.0, 1.0);
|
||||
|
||||
let version = unsafe {
|
||||
let data = CStr::from_ptr(gl::GetString(gl::VERSION) as *const _).to_bytes().to_vec();
|
||||
String::from_utf8(data).unwrap()
|
||||
};
|
||||
|
||||
println!("WebRender - OpenGL version new {}", version);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn wr_state_new(width: u32, height: u32, pipeline: u64) -> *mut WrState {
|
||||
assert!(unsafe { is_in_compositor_thread() });
|
||||
let pipeline_id = u64_to_pipeline_id(pipeline);
|
||||
|
||||
let state = Box::new(WrState {
|
||||
size: (width, height),
|
||||
pipeline_id: pipeline_id,
|
||||
z_index: 0,
|
||||
frame_builder: WebRenderFrameBuilder::new(pipeline_id),
|
||||
});
|
||||
|
||||
Box::into_raw(state)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn wr_state_delete(state:*mut WrState) {
|
||||
assert!(unsafe { is_in_compositor_thread() });
|
||||
|
||||
unsafe {
|
||||
Box::from_raw(state);
|
||||
}
|
||||
}
|
||||
|
||||
struct CppNotifier {
|
||||
window_id: u64,
|
||||
}
|
||||
|
||||
unsafe impl Send for CppNotifier {}
|
||||
|
||||
extern {
|
||||
fn wr_notifier_new_frame_ready(window_id: u64);
|
||||
fn wr_notifier_new_scroll_frame_ready(window_id: u64, composite_needed: bool);
|
||||
fn wr_notifier_pipeline_size_changed(window_id: u64, pipeline: u64, new_width: f32, new_height: f32);
|
||||
// TODO: Waiting for PR #688
|
||||
fn wr_notifier_external_event(window_id: u64, raw_event: usize);
|
||||
}
|
||||
|
||||
impl webrender_traits::RenderNotifier for CppNotifier {
|
||||
fn new_frame_ready(&mut self) {
|
||||
unsafe {
|
||||
wr_notifier_new_frame_ready(self.window_id);
|
||||
}
|
||||
}
|
||||
|
||||
fn new_scroll_frame_ready(&mut self, composite_needed: bool) {
|
||||
unsafe {
|
||||
wr_notifier_new_scroll_frame_ready(self.window_id, composite_needed);
|
||||
}
|
||||
}
|
||||
|
||||
fn pipeline_size_changed(&mut self,
|
||||
pipeline_id: PipelineId,
|
||||
new_size: Option<LayoutSize>) {
|
||||
let (w, h) = if let Some(size) = new_size {
|
||||
(size.width, size.height)
|
||||
} else {
|
||||
(0.0, 0.0)
|
||||
};
|
||||
unsafe {
|
||||
let id = pipeline_id_to_u64(pipeline_id);
|
||||
wr_notifier_pipeline_size_changed(self.window_id, id, w, h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// RenderThread WIP notes:
|
||||
// In order to separate the compositor thread (or ipc receiver) and the render
|
||||
// thread, some of the logic below needs to be rewritten. In particular
|
||||
// the WrWindowState and Notifier implementations aren't designed to work with
|
||||
// a separate render thread.
|
||||
// As part of that I am moving the bindings closer to WebRender's API boundary,
|
||||
// and moving more of the logic in C++ land.
|
||||
// This work is tracked by bug 1328602.
|
||||
//
|
||||
// See RenderThread.h for some notes about how the pieces fit together.
|
||||
|
||||
pub struct WebRenderFrameBuilder {
|
||||
pub root_pipeline_id: PipelineId,
|
||||
pub dl_builder: webrender_traits::DisplayListBuilder,
|
||||
|
@ -219,7 +55,6 @@ impl WebRenderFrameBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
// XXX (bug 1328602) - This will be removed soon-ish.
|
||||
struct Notifier {
|
||||
render_notifier: Arc<(Mutex<bool>, Condvar)>,
|
||||
}
|
||||
|
@ -241,7 +76,6 @@ impl webrender_traits::RenderNotifier for Notifier {
|
|||
}
|
||||
}
|
||||
|
||||
// XXX (bug 1328602) - This will be removed soon-ish.
|
||||
pub struct WrWindowState {
|
||||
renderer: Renderer,
|
||||
api: webrender_traits::RenderApi,
|
||||
|
@ -368,7 +202,7 @@ pub extern fn wr_init_window(root_pipeline_id: u64,
|
|||
}));
|
||||
}
|
||||
|
||||
let pipeline_id = u64_to_pipeline_id(root_pipeline_id);
|
||||
let pipeline_id = PipelineId((root_pipeline_id >> 32) as u32, root_pipeline_id as u32);
|
||||
api.set_root_pipeline(pipeline_id);
|
||||
|
||||
let state = Box::new(WrWindowState {
|
||||
|
@ -386,7 +220,7 @@ pub extern fn wr_init_window(root_pipeline_id: u64,
|
|||
#[no_mangle]
|
||||
pub extern fn wr_create(window: &mut WrWindowState, width: u32, height: u32, layers_id: u64) -> *mut WrState {
|
||||
assert!( unsafe { is_in_compositor_thread() });
|
||||
let pipeline_id = u64_to_pipeline_id(layers_id);
|
||||
let pipeline_id = PipelineId((layers_id >> 32) as u32, layers_id as u32);
|
||||
|
||||
let builder = WebRenderFrameBuilder::new(pipeline_id);
|
||||
|
||||
|
@ -499,7 +333,7 @@ fn wait_for_epoch(window: &mut WrWindowState) {
|
|||
|
||||
#[no_mangle]
|
||||
pub fn wr_composite_window(window: &mut WrWindowState) {
|
||||
assert!(unsafe { is_in_render_thread() });
|
||||
assert!( unsafe { is_in_compositor_thread() });
|
||||
|
||||
gl::clear(gl::COLOR_BUFFER_BIT);
|
||||
|
||||
|
|
|
@ -8,15 +8,8 @@
|
|||
#define WR_h
|
||||
extern "C" {
|
||||
bool is_in_compositor_thread();
|
||||
bool is_in_render_thread();
|
||||
void* get_proc_address_from_glcontext(void* glcontext_ptr, const char* procname);
|
||||
|
||||
struct WrRenderer;
|
||||
void wr_renderer_update(WrRenderer* renderer);
|
||||
void wr_renderer_render(WrRenderer* renderer, uint32_t width, uint32_t height);
|
||||
void wr_renderer_set_profiler_enabled(WrRenderer* renderer, bool enabled);
|
||||
bool wr_renderer_current_epoch(WrRenderer* renderer, uint64_t pipeline_id, uint32_t* out_epoch);
|
||||
|
||||
enum WRImageFormat {
|
||||
Invalid,
|
||||
A8,
|
||||
|
@ -247,18 +240,4 @@ WR_FUNC;
|
|||
|
||||
#undef WR_FUNC
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
namespace wr {
|
||||
|
||||
struct WindowId {
|
||||
explicit WindowId(uint64_t aHandle) : mHandle(aHandle) {}
|
||||
bool operator<(const WindowId& aOther) const { return mHandle < aOther.mHandle; }
|
||||
|
||||
uint64_t mHandle;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче