2012-07-17 23:59:45 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set sw=2 ts=8 et tw=80 : */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* 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/. */
|
2012-01-19 14:45:37 +00:00
|
|
|
|
|
|
|
#ifndef mozilla_layers_CompositorChild_h
|
|
|
|
#define mozilla_layers_CompositorChild_h
|
|
|
|
|
2013-08-11 23:17:23 +00:00
|
|
|
#include "base/basictypes.h" // for DISALLOW_EVIL_CONSTRUCTORS
|
|
|
|
#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2
|
|
|
|
#include "mozilla/Attributes.h" // for MOZ_OVERRIDE
|
|
|
|
#include "mozilla/ipc/ProtocolUtils.h"
|
2012-01-19 14:45:37 +00:00
|
|
|
#include "mozilla/layers/PCompositorChild.h"
|
2013-08-11 23:17:23 +00:00
|
|
|
#include "nsAutoPtr.h" // for nsRefPtr
|
2013-12-19 20:19:25 +00:00
|
|
|
#include "nsClassHashtable.h" // for nsClassHashtable
|
2013-08-11 23:17:23 +00:00
|
|
|
#include "nsCOMPtr.h" // for nsCOMPtr
|
2013-12-19 20:19:25 +00:00
|
|
|
#include "nsHashKeys.h" // for nsUint64HashKey
|
2013-08-11 23:17:23 +00:00
|
|
|
#include "nsISupportsImpl.h" // for NS_INLINE_DECL_REFCOUNTING
|
2014-07-04 18:04:12 +00:00
|
|
|
#include "ThreadSafeRefcountingWithMainThreadDestruction.h"
|
2014-05-23 18:19:00 +00:00
|
|
|
#include "nsWeakReference.h"
|
2013-08-11 23:17:23 +00:00
|
|
|
|
|
|
|
class nsIObserver;
|
2012-01-19 14:45:37 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
2014-05-23 18:19:00 +00:00
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
class TabChild;
|
|
|
|
}
|
|
|
|
|
2012-01-19 14:45:37 +00:00
|
|
|
namespace layers {
|
|
|
|
|
2014-05-23 18:19:00 +00:00
|
|
|
using mozilla::dom::TabChild;
|
|
|
|
|
2013-11-21 22:07:56 +00:00
|
|
|
class ClientLayerManager;
|
2012-01-19 14:45:37 +00:00
|
|
|
class CompositorParent;
|
2014-06-19 00:57:51 +00:00
|
|
|
struct FrameMetrics;
|
2012-01-19 14:45:37 +00:00
|
|
|
|
2014-04-04 16:27:02 +00:00
|
|
|
class CompositorChild MOZ_FINAL : public PCompositorChild
|
2012-01-19 14:45:37 +00:00
|
|
|
{
|
2014-07-04 18:04:12 +00:00
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION(CompositorChild)
|
|
|
|
|
2012-01-19 14:45:37 +00:00
|
|
|
public:
|
2014-08-20 04:55:14 +00:00
|
|
|
explicit CompositorChild(ClientLayerManager *aLayerManager);
|
2012-01-19 14:45:37 +00:00
|
|
|
|
|
|
|
void Destroy();
|
|
|
|
|
2013-12-19 20:19:25 +00:00
|
|
|
/**
|
|
|
|
* Lookup the FrameMetrics shared by the compositor process with the
|
|
|
|
* associated FrameMetrics::ViewID. The returned FrameMetrics is used
|
|
|
|
* in progressive paint calculations.
|
|
|
|
*/
|
|
|
|
bool LookupCompositorFrameMetrics(const FrameMetrics::ViewID aId, FrameMetrics&);
|
|
|
|
|
2012-07-17 23:59:45 +00:00
|
|
|
/**
|
|
|
|
* We're asked to create a new Compositor in response to an Opens()
|
|
|
|
* or Bridge() request from our parent process. The Transport is to
|
|
|
|
* the compositor's context.
|
|
|
|
*/
|
2013-09-26 04:19:09 +00:00
|
|
|
static PCompositorChild*
|
2012-07-17 23:59:45 +00:00
|
|
|
Create(Transport* aTransport, ProcessId aOtherProcess);
|
|
|
|
|
2013-12-19 20:19:25 +00:00
|
|
|
static CompositorChild* Get();
|
2012-07-17 23:59:45 +00:00
|
|
|
|
2012-08-26 01:27:28 +00:00
|
|
|
static bool ChildProcessHasCompositor() { return sCompositor != nullptr; }
|
2013-11-21 22:07:56 +00:00
|
|
|
|
|
|
|
virtual bool RecvInvalidateAll() MOZ_OVERRIDE;
|
2014-05-08 15:32:00 +00:00
|
|
|
virtual bool RecvOverfill(const uint32_t &aOverfill) MOZ_OVERRIDE;
|
|
|
|
void AddOverfillObserver(ClientLayerManager* aLayerManager);
|
2013-11-21 22:07:56 +00:00
|
|
|
|
2014-05-28 21:42:14 +00:00
|
|
|
virtual bool RecvDidComposite(const uint64_t& aId, const uint64_t& aTransactionId) MOZ_OVERRIDE;
|
2014-03-07 03:24:32 +00:00
|
|
|
|
2014-05-23 18:19:00 +00:00
|
|
|
/**
|
|
|
|
* Request that the parent tell us when graphics are ready on GPU.
|
|
|
|
* When we get that message, we bounce it to the TabParent via
|
|
|
|
* the TabChild
|
|
|
|
* @param tabChild The object to bounce the note to. Non-NULL.
|
|
|
|
*/
|
|
|
|
void RequestNotifyAfterRemotePaint(TabChild* aTabChild);
|
|
|
|
|
2014-09-04 12:20:45 +00:00
|
|
|
void CancelNotifyAfterRemotePaint(TabChild* aTabChild);
|
|
|
|
|
2014-04-04 16:27:02 +00:00
|
|
|
private:
|
|
|
|
// Private destructor, to discourage deletion outside of Release():
|
|
|
|
virtual ~CompositorChild();
|
|
|
|
|
2013-04-24 18:42:40 +00:00
|
|
|
virtual PLayerTransactionChild*
|
2013-08-18 06:46:16 +00:00
|
|
|
AllocPLayerTransactionChild(const nsTArray<LayersBackend>& aBackendHints,
|
2013-07-08 15:48:39 +00:00
|
|
|
const uint64_t& aId,
|
2013-08-04 07:46:17 +00:00
|
|
|
TextureFactoryIdentifier* aTextureFactoryIdentifier,
|
|
|
|
bool* aSuccess) MOZ_OVERRIDE;
|
2013-04-24 18:42:40 +00:00
|
|
|
|
2013-07-08 15:48:39 +00:00
|
|
|
virtual bool DeallocPLayerTransactionChild(PLayerTransactionChild *aChild) MOZ_OVERRIDE;
|
2012-01-19 14:45:37 +00:00
|
|
|
|
2012-07-17 23:59:45 +00:00
|
|
|
virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
|
|
|
|
|
2013-12-19 20:19:25 +00:00
|
|
|
virtual bool RecvSharedCompositorFrameMetrics(const mozilla::ipc::SharedMemoryBasic::Handle& metrics,
|
|
|
|
const CrossProcessMutexHandle& handle,
|
|
|
|
const uint32_t& aAPZCId) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual bool RecvReleaseSharedCompositorFrameMetrics(const ViewID& aId,
|
|
|
|
const uint32_t& aAPZCId) MOZ_OVERRIDE;
|
|
|
|
|
2014-05-23 18:19:00 +00:00
|
|
|
virtual bool
|
|
|
|
RecvRemotePaintIsReady() MOZ_OVERRIDE;
|
|
|
|
|
2013-12-19 20:19:25 +00:00
|
|
|
// Class used to store the shared FrameMetrics, mutex, and APZCId in a hash table
|
|
|
|
class SharedFrameMetricsData {
|
|
|
|
public:
|
|
|
|
SharedFrameMetricsData(
|
|
|
|
const mozilla::ipc::SharedMemoryBasic::Handle& metrics,
|
|
|
|
const CrossProcessMutexHandle& handle,
|
|
|
|
const uint32_t& aAPZCId);
|
|
|
|
|
|
|
|
~SharedFrameMetricsData();
|
|
|
|
|
|
|
|
void CopyFrameMetrics(FrameMetrics* aFrame);
|
|
|
|
FrameMetrics::ViewID GetViewID();
|
|
|
|
uint32_t GetAPZCId();
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Pointer to the class that allows access to the shared memory that contains
|
|
|
|
// the shared FrameMetrics
|
2014-07-16 19:39:03 +00:00
|
|
|
nsRefPtr<mozilla::ipc::SharedMemoryBasic> mBuffer;
|
2013-12-19 20:19:25 +00:00
|
|
|
CrossProcessMutex* mMutex;
|
|
|
|
// Unique ID of the APZC that is sharing the FrameMetrics
|
|
|
|
uint32_t mAPZCId;
|
|
|
|
};
|
|
|
|
|
2013-11-21 22:07:56 +00:00
|
|
|
nsRefPtr<ClientLayerManager> mLayerManager;
|
2012-01-19 14:45:37 +00:00
|
|
|
|
2013-12-19 20:19:25 +00:00
|
|
|
// The ViewID of the FrameMetrics is used as the key for this hash table.
|
|
|
|
// While this should be safe to use since the ViewID is unique
|
|
|
|
nsClassHashtable<nsUint64HashKey, SharedFrameMetricsData> mFrameMetricsTable;
|
|
|
|
|
2012-07-17 23:59:45 +00:00
|
|
|
// When we're in a child process, this is the process-global
|
|
|
|
// compositor that we use to forward transactions directly to the
|
|
|
|
// compositor context in another process.
|
|
|
|
static CompositorChild* sCompositor;
|
|
|
|
|
2014-05-23 18:19:00 +00:00
|
|
|
// Weakly hold the TabChild that made a request to be alerted when
|
|
|
|
// the transaction has been received.
|
|
|
|
nsWeakPtr mWeakTabChild; // type is TabChild
|
|
|
|
|
2012-01-19 14:45:37 +00:00
|
|
|
DISALLOW_EVIL_CONSTRUCTORS(CompositorChild);
|
2014-05-08 15:32:00 +00:00
|
|
|
|
|
|
|
// When we receive overfill numbers, notify these client layer managers
|
|
|
|
nsAutoTArray<ClientLayerManager*,0> mOverfillObservers;
|
2012-01-19 14:45:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // layers
|
|
|
|
} // mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_layers_CompositorChild_h
|