1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/layers/ipc/CompositorChild.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,122 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set sw=2 ts=8 et tw=80 : */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef mozilla_layers_CompositorChild_h 1.11 +#define mozilla_layers_CompositorChild_h 1.12 + 1.13 +#include "base/basictypes.h" // for DISALLOW_EVIL_CONSTRUCTORS 1.14 +#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2 1.15 +#include "mozilla/Attributes.h" // for MOZ_OVERRIDE 1.16 +#include "mozilla/ipc/ProtocolUtils.h" 1.17 +#include "mozilla/layers/PCompositorChild.h" 1.18 +#include "nsAutoPtr.h" // for nsRefPtr 1.19 +#include "nsClassHashtable.h" // for nsClassHashtable 1.20 +#include "nsCOMPtr.h" // for nsCOMPtr 1.21 +#include "nsHashKeys.h" // for nsUint64HashKey 1.22 +#include "nsISupportsImpl.h" // for NS_INLINE_DECL_REFCOUNTING 1.23 + 1.24 +class nsIObserver; 1.25 + 1.26 +namespace mozilla { 1.27 +namespace layers { 1.28 + 1.29 +class ClientLayerManager; 1.30 +class CompositorParent; 1.31 +class FrameMetrics; 1.32 + 1.33 +class CompositorChild MOZ_FINAL : public PCompositorChild 1.34 +{ 1.35 + NS_INLINE_DECL_REFCOUNTING(CompositorChild) 1.36 +public: 1.37 + CompositorChild(ClientLayerManager *aLayerManager); 1.38 + 1.39 + void Destroy(); 1.40 + 1.41 + /** 1.42 + * Lookup the FrameMetrics shared by the compositor process with the 1.43 + * associated FrameMetrics::ViewID. The returned FrameMetrics is used 1.44 + * in progressive paint calculations. 1.45 + */ 1.46 + bool LookupCompositorFrameMetrics(const FrameMetrics::ViewID aId, FrameMetrics&); 1.47 + 1.48 + /** 1.49 + * We're asked to create a new Compositor in response to an Opens() 1.50 + * or Bridge() request from our parent process. The Transport is to 1.51 + * the compositor's context. 1.52 + */ 1.53 + static PCompositorChild* 1.54 + Create(Transport* aTransport, ProcessId aOtherProcess); 1.55 + 1.56 + static CompositorChild* Get(); 1.57 + 1.58 + static bool ChildProcessHasCompositor() { return sCompositor != nullptr; } 1.59 + 1.60 + virtual bool RecvInvalidateAll() MOZ_OVERRIDE; 1.61 + 1.62 + virtual bool RecvDidComposite(const uint64_t& aId) MOZ_OVERRIDE; 1.63 + 1.64 +private: 1.65 + // Private destructor, to discourage deletion outside of Release(): 1.66 + virtual ~CompositorChild(); 1.67 + 1.68 + virtual PLayerTransactionChild* 1.69 + AllocPLayerTransactionChild(const nsTArray<LayersBackend>& aBackendHints, 1.70 + const uint64_t& aId, 1.71 + TextureFactoryIdentifier* aTextureFactoryIdentifier, 1.72 + bool* aSuccess) MOZ_OVERRIDE; 1.73 + 1.74 + virtual bool DeallocPLayerTransactionChild(PLayerTransactionChild *aChild) MOZ_OVERRIDE; 1.75 + 1.76 + virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE; 1.77 + 1.78 + virtual bool RecvSharedCompositorFrameMetrics(const mozilla::ipc::SharedMemoryBasic::Handle& metrics, 1.79 + const CrossProcessMutexHandle& handle, 1.80 + const uint32_t& aAPZCId) MOZ_OVERRIDE; 1.81 + 1.82 + virtual bool RecvReleaseSharedCompositorFrameMetrics(const ViewID& aId, 1.83 + const uint32_t& aAPZCId) MOZ_OVERRIDE; 1.84 + 1.85 + // Class used to store the shared FrameMetrics, mutex, and APZCId in a hash table 1.86 + class SharedFrameMetricsData { 1.87 + public: 1.88 + SharedFrameMetricsData( 1.89 + const mozilla::ipc::SharedMemoryBasic::Handle& metrics, 1.90 + const CrossProcessMutexHandle& handle, 1.91 + const uint32_t& aAPZCId); 1.92 + 1.93 + ~SharedFrameMetricsData(); 1.94 + 1.95 + void CopyFrameMetrics(FrameMetrics* aFrame); 1.96 + FrameMetrics::ViewID GetViewID(); 1.97 + uint32_t GetAPZCId(); 1.98 + 1.99 + private: 1.100 + // Pointer to the class that allows access to the shared memory that contains 1.101 + // the shared FrameMetrics 1.102 + mozilla::ipc::SharedMemoryBasic* mBuffer; 1.103 + CrossProcessMutex* mMutex; 1.104 + // Unique ID of the APZC that is sharing the FrameMetrics 1.105 + uint32_t mAPZCId; 1.106 + }; 1.107 + 1.108 + nsRefPtr<ClientLayerManager> mLayerManager; 1.109 + 1.110 + // The ViewID of the FrameMetrics is used as the key for this hash table. 1.111 + // While this should be safe to use since the ViewID is unique 1.112 + nsClassHashtable<nsUint64HashKey, SharedFrameMetricsData> mFrameMetricsTable; 1.113 + 1.114 + // When we're in a child process, this is the process-global 1.115 + // compositor that we use to forward transactions directly to the 1.116 + // compositor context in another process. 1.117 + static CompositorChild* sCompositor; 1.118 + 1.119 + DISALLOW_EVIL_CONSTRUCTORS(CompositorChild); 1.120 +}; 1.121 + 1.122 +} // layers 1.123 +} // mozilla 1.124 + 1.125 +#endif // mozilla_layers_CompositorChild_h