Bug 854421 - Part 6: Add gfx API for allocating transaction ids. r=roc
☠☠ backed out by 892713a8dccb ☠ ☠
authorMatt Woodrow <mwoodrow@mozilla.com>
Thu, 29 May 2014 09:42:17 +1200
changeset 204731 056cc43a50b64d2d5d80addfa904560410fb5551
parent 204730 1d9f1a4d783838c7d9a2054d97a8cb09eea17150
child 204732 3f58a7521a51f14e591e9f53017c7cc28e2eb1b1
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs854421
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 854421 - Part 6: Add gfx API for allocating transaction ids. r=roc
gfx/layers/TransactionIdAllocator.h
gfx/layers/moz.build
layout/base/nsRefreshDriver.cpp
layout/base/nsRefreshDriver.h
new file mode 100644
--- /dev/null
+++ b/gfx/layers/TransactionIdAllocator.h
@@ -0,0 +1,52 @@
+/* -*- 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/. */
+
+#ifndef GFX_TRANSACTION_ID_ALLOCATOR_H
+#define GFX_TRANSACTION_ID_ALLOCATOR_H
+
+#include "nsISupportsImpl.h"
+
+namespace mozilla {
+namespace layers {
+
+class TransactionIdAllocator {
+public:
+  NS_INLINE_DECL_REFCOUNTING(TransactionIdAllocator)
+
+  virtual ~TransactionIdAllocator() {}
+
+  /**
+   * Allocate a unique id number for the current refresh tick, can
+   * only be called while IsInRefresh().
+   *
+   * If too many id's are allocated without being returned then
+   * the refresh driver will suspend until they catch up.
+   */
+  virtual uint64_t GetTransactionId() = 0;
+
+  /**
+   * Notify that all work (including asynchronous composites)
+   * for a given transaction id has been completed.
+   *
+   * If the refresh driver has been suspended because
+   * of having too many outstanding id's, then this may
+   * resume it.
+   */
+  virtual void NotifyTransactionCompleted(uint64_t aTransactionId) = 0;
+
+  /**
+   * Revoke a transaction id that isn't needed to track
+   * completion of asynchronous work. This is similar
+   * to NotifyTransactionCompleted except avoids
+   * return ordering issues.
+   */
+  virtual void RevokeTransactionId(uint64_t aTransactionId) = 0;
+};
+
+}
+}
+
+
+#endif /* GFX_TRANSACTION_ID_ALLOCATOR_H */
--- a/gfx/layers/moz.build
+++ b/gfx/layers/moz.build
@@ -158,16 +158,17 @@ EXPORTS.mozilla.layers += [
     'opengl/CompositorOGL.h',
     'opengl/GrallocTextureClient.h',
     'opengl/GrallocTextureHost.h',
     'opengl/MacIOSurfaceTextureClientOGL.h',
     'opengl/MacIOSurfaceTextureHostOGL.h',
     'opengl/TextureClientOGL.h',
     'opengl/TextureHostOGL.h',
     'RenderTrace.h',
+    'TransactionIdAllocator.h',
     'YCbCrImageDataSerializer.h',
 ]
 
 if CONFIG['MOZ_X11']:
     EXPORTS.mozilla.layers += [
         'basic/TextureClientX11.h',
         'basic/X11TextureSourceBasic.h',
         'composite/X11TextureHost.h',
--- a/layout/base/nsRefreshDriver.cpp
+++ b/layout/base/nsRefreshDriver.cpp
@@ -1007,22 +1007,16 @@ nsRefreshDriver::ArrayFor(mozFlushType a
       return mObservers[2];
     default:
       NS_ABORT_IF_FALSE(false, "bad flush type");
       return *static_cast<ObserverArray*>(nullptr);
   }
 }
 
 /*
- * nsISupports implementation
- */
-
-NS_IMPL_ISUPPORTS(nsRefreshDriver, nsISupports)
-
-/*
  * nsITimerCallback implementation
  */
 
 void
 nsRefreshDriver::DoTick()
 {
   NS_PRECONDITION(!IsFrozen(), "Why are we notified while frozen?");
   NS_PRECONDITION(mPresContext, "Why are we notified after disconnection?");
--- a/layout/base/nsRefreshDriver.h
+++ b/layout/base/nsRefreshDriver.h
@@ -17,16 +17,17 @@
 #include "nsTObserverArray.h"
 #include "nsTArray.h"
 #include "nsTHashtable.h"
 #include "nsClassHashtable.h"
 #include "nsHashKeys.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/Maybe.h"
 #include "GeckoProfiler.h"
+#include "mozilla/layers/TransactionIdAllocator.h"
 
 class nsPresContext;
 class nsIPresShell;
 class nsIDocument;
 class imgIRequest;
 class nsIRunnable;
 
 namespace mozilla {
@@ -57,27 +58,24 @@ public:
  * that a refresh has occurred. Callers must ensure an observer is removed
  * before it is destroyed.
  */
 class nsAPostRefreshObserver {
 public:
   virtual void DidRefresh() = 0;
 };
 
-class nsRefreshDriver MOZ_FINAL : public nsISupports {
+class nsRefreshDriver MOZ_FINAL : public mozilla::layers::TransactionIdAllocator {
 public:
   nsRefreshDriver(nsPresContext *aPresContext);
   ~nsRefreshDriver();
 
   static void InitializeStatics();
   static void Shutdown();
 
-  // nsISupports implementation
-  NS_DECL_ISUPPORTS
-
   /**
    * Methods for testing, exposed via nsIDOMWindowUtils.  See
    * nsIDOMWindowUtils.advanceTimeAndRefresh for description.
    */
   void AdvanceTimeAndRefresh(int64_t aMilliseconds);
   void RestoreNormalRefresh();
   void DoTick();
   bool IsTestControllingRefreshesEnabled() const
@@ -267,42 +265,20 @@ public:
 
   /**
    * Default interval the refresh driver uses, in ms.
    */
   static int32_t DefaultInterval();
 
   bool IsInRefresh() { return mInRefresh; }
 
-  /**
-   * Allocate a unique id number for the current refresh tick, can
-   * only be called while IsInRefresh().
-   *
-   * If too many id's are allocated without being returned then
-   * the refresh driver will suspend until they catch up.
-   */
-  uint64_t GetTransactionId();
-
-  /**
-   * Notify that all work (including asynchronous composites)
-   * for a given transaction id has been completed.
-   *
-   * If the refresh driver has been suspended because
-   * of having too many outstanding id's, then this may
-   * resume it.
-   */
-  void NotifyTransactionCompleted(uint64_t aTransactionId);
-
-  /**
-   * Revoke a transaction id that isn't needed to track
-   * completion of asynchronous work. This is similar
-   * to NotifyTransactionCompleted except avoids
-   * return ordering issues.
-   */
-  void RevokeTransactionId(uint64_t aTransactionId);
+  // mozilla::layers::TransactionIdAllocator
+  virtual uint64_t GetTransactionId() MOZ_OVERRIDE;
+  void NotifyTransactionCompleted(uint64_t aTransactionId) MOZ_OVERRIDE;
+  void RevokeTransactionId(uint64_t aTransactionId) MOZ_OVERRIDE;
 
 private:
   typedef nsTObserverArray<nsARefreshObserver*> ObserverArray;
   typedef nsTHashtable<nsISupportsHashKey> RequestTable;
   struct ImageStartData {
     ImageStartData()
     {
     }