author Kartikaya Gupta <>
Tue, 06 Mar 2018 10:25:37 -0500
changeset 461762 322301ce2f826169d4ed386feb6981430b0c0b2a
parent 461363 da64726bf399abe8936889dc2e2c04acc8cec782
child 461763 54e61d972192277357cec0ee2ccd064f03ada8ea
permissions -rw-r--r--
Bug 1442627 - Switch some call sites in WebRenderBridgeParent to use APZSampler. r=botond MozReview-Commit-ID: AqtcAyTkcEK

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 */

#ifndef mozilla_layers_APZSampler_h
#define mozilla_layers_APZSampler_h

#include "mozilla/layers/APZTestData.h"
#include "mozilla/Maybe.h"
#include "nsTArray.h"

namespace mozilla {

class TimeStamp;

namespace wr {
class TransactionBuilder;
struct WrTransformProperty;
} // namespace wr

namespace layers {

class APZCTreeManager;
class FocusTarget;
class Layer;
class WebRenderScrollData;

 * This interface is used to interact with the APZ code from the compositor
 * thread. It internally redispatches the functions to the sampler thread
 * in the case where the two threads are not the same.
class APZSampler {

  explicit APZSampler(const RefPtr<APZCTreeManager>& aApz);

  void ClearTree();
  void UpdateFocusState(uint64_t aRootLayerTreeId,
                        uint64_t aOriginatingLayersId,
                        const FocusTarget& aFocusTarget);
  void UpdateHitTestingTree(uint64_t aRootLayerTreeId,
                            Layer* aRoot,
                            bool aIsFirstPaint,
                            uint64_t aOriginatingLayersId,
                            uint32_t aPaintSequenceNumber);
  void UpdateHitTestingTree(uint64_t aRootLayerTreeId,
                            const WebRenderScrollData& aScrollData,
                            bool aIsFirstPaint,
                            uint64_t aOriginatingLayersId,
                            uint32_t aPaintSequenceNumber);

  void NotifyLayerTreeAdopted(uint64_t aLayersId,
                              const RefPtr<APZSampler>& aOldSampler);
  void NotifyLayerTreeRemoved(uint64_t aLayersId);

  bool PushStateToWR(wr::TransactionBuilder& aTxn,
                     const TimeStamp& aSampleTime,
                     nsTArray<wr::WrTransformProperty>& aTransformArray);

  bool GetAPZTestData(uint64_t aLayersId, APZTestData* aOutData);

  virtual ~APZSampler();

  RefPtr<APZCTreeManager> mApz;

} // namespace layers
} // namespace mozilla

#endif // mozilla_layers_APZSampler_h