Merge 3c3cd985155f9a0c016b2087fce7a41482dfda5f to graphics.

This commit is contained in:
Morris Tseng 2016-12-01 10:25:55 +08:00
Родитель 780eca450f 133d7a894f
Коммит 1565dfd024
7 изменённых файлов: 47 добавлений и 4 удалений

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

@ -28,6 +28,7 @@
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/TabParent.h"
#include "mozilla/gfx/2D.h" // for DrawTarget
#include "mozilla/gfx/GPUChild.h" // for GfxPrefValue
#include "mozilla/gfx/Point.h" // for IntSize
#include "mozilla/gfx/Rect.h" // for IntSize
#include "VRManager.h" // for VRManager
@ -238,6 +239,11 @@ CompositorBridgeParent::Setup()
MOZ_ASSERT(!sCompositorMap);
sCompositorMap = new CompositorMap;
gfxPrefs::SetWebRenderProfilerEnabledChangeCallback(
[](const GfxPrefValue& aValue) -> void {
CompositorBridgeParent::SetWebRenderProfilerEnabled(aValue.get_bool());
});
}
void
@ -246,6 +252,7 @@ CompositorBridgeParent::Shutdown()
MOZ_ASSERT(sCompositorMap);
MOZ_ASSERT(sCompositorMap->empty());
sCompositorMap = nullptr;
gfxPrefs::SetWebRenderProfilerEnabledChangeCallback(nullptr);
}
void
@ -1602,6 +1609,18 @@ CompositorBridgeParent::DeallocPWebRenderBridgeParent(PWebRenderBridgeParent* aA
return true;
}
void
CompositorBridgeParent::SetWebRenderProfilerEnabled(bool aEnabled)
{
MonitorAutoLock lock(*sIndirectLayerTreesLock);
for (auto it = sIndirectLayerTrees.begin(); it != sIndirectLayerTrees.end(); it++) {
LayerTreeState* state = &it->second;
if (state->mWRBridge) {
state->mWRBridge->SetWebRenderProfilerEnabled(aEnabled);
}
}
}
void
EraseLayerState(uint64_t aId)
{

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

@ -462,6 +462,7 @@ public:
PWebRenderBridgeParent* AllocPWebRenderBridgeParent(const uint64_t& aPipelineId,
TextureFactoryIdentifier* aTextureFactoryIdentifier) override;
bool DeallocPWebRenderBridgeParent(PWebRenderBridgeParent* aActor) override;
static void SetWebRenderProfilerEnabled(bool aEnabled);
private:

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

@ -47,7 +47,7 @@ WebRenderBridgeParent::WebRenderBridgeParent(CompositorBridgeParentBase* aCompos
// i.e. the one created by the CompositorBridgeParent as opposed to the
// CrossProcessCompositorBridgeParent
MOZ_ASSERT(mWidget);
mWRWindowState = wr_init_window(mPipelineId);
mWRWindowState = wr_init_window(mPipelineId, gfxPrefs::WebRenderProfilerEnabled());
}
if (mWidget) {
mCompositorScheduler = new CompositorVsyncScheduler(this, mWidget);
@ -464,5 +464,14 @@ WebRenderBridgeParent::DeallocPCompositableParent(PCompositableParent* aActor)
return true;
}
void
WebRenderBridgeParent::SetWebRenderProfilerEnabled(bool aEnabled)
{
if (mWidget) {
// Only set the flag to "root" WebRenderBridgeParent.
wr_profiler_set_enabled(mWRWindowState, aEnabled);
}
}
} // namespace layers
} // namespace mozilla

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

@ -78,6 +78,7 @@ public:
mozilla::ipc::IPCResult RecvClearCachedResources() override;
void ActorDestroy(ActorDestroyReason aWhy) override;
void SetWebRenderProfilerEnabled(bool aEnabled);
void Destroy();

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

@ -422,6 +422,7 @@ private:
DECL_GFX_PREF(Live, "gfx.vsync.collect-scroll-transforms", CollectScrollTransforms, bool, false);
DECL_GFX_PREF(Once, "gfx.vsync.compositor.unobserve-count", CompositorUnobserveCount, int32_t, 10);
DECL_GFX_PREF(Live, "gfx.webrender.profiler.enable", WebRenderProfilerEnabled, bool, false);
// Use vsync events generated by hardware
DECL_GFX_PREF(Once, "gfx.work-around-driver-bugs", WorkAroundDriverBugs, bool, true);
DECL_GFX_PREF(Once, "gfx.screen-mirroring.enabled", ScreenMirroringEnabled, bool, false);

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

@ -279,7 +279,9 @@ impl ExternalImageHandler for WrExternalImageHandler {
}
#[no_mangle]
pub extern fn wr_init_window(root_pipeline_id: u64, external_image_handler: *mut WrExternalImageHandler) -> *mut WrWindowState {
pub extern fn wr_init_window(root_pipeline_id: u64,
enable_profiler: bool,
external_image_handler: *mut WrExternalImageHandler) -> *mut WrWindowState {
let library = GlLibrary::new();
gl::load_with(|symbol| library.query(symbol));
gl::clear_color(0.3, 0.0, 0.0, 1.0);
@ -297,7 +299,7 @@ pub extern fn wr_init_window(root_pipeline_id: u64, external_image_handler: *mut
enable_aa: false,
enable_subpixel_aa: false,
enable_msaa: false,
enable_profiler: false,
enable_profiler: enable_profiler,
enable_recording: false,
enable_scrollbars: false,
precache_shaders: false,
@ -625,3 +627,9 @@ pub extern fn wr_free_buffer(vec_ptr: *mut c_uchar, length: u32, capacity: u32)
let rebuilt = Vec::from_raw_parts(vec_ptr, length as usize, capacity as usize);
}
}
#[no_mangle]
pub extern fn wr_profiler_set_enabled(window: &mut WrWindowState, enabled: bool)
{
window.renderer.set_profiler_enabled(enabled);
}

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

@ -95,7 +95,7 @@ struct wrstate;
#endif
WR_INLINE wrwindowstate*
wr_init_window(uint64_t root_pipeline_id, WRExternalImageHandler* handler = nullptr)
wr_init_window(uint64_t root_pipeline_id, bool enable_profiler, WRExternalImageHandler* handler = nullptr)
WR_FUNC;
WR_INLINE wrstate*
@ -182,6 +182,10 @@ wr_free_buffer(const uint8_t* pointer, uint32_t length, uint32_t capacity)
WR_FUNC;
WR_INLINE void
wr_profiler_set_enabled(wrwindowstate* wrWindow, bool enabled)
WR_FUNC;
#undef WR_FUNC
}
#endif