Bug 1393031 - Make ResourceUpdateQueue move-only. r=sotaro
authorNicolas Silva <nsilva@mozilla.com>
Mon, 04 Sep 2017 13:59:17 +0200
changeset 428333 684dd3236401702bac2c609066191b85e7368646
parent 428332 73cbc76a296bd9558d3ec3bee9dfb1ec26c08337
child 428334 cf18746c20ea99f41fd12e467ad5f4d81d06451a
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssotaro
bugs1393031
milestone57.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 1393031 - Make ResourceUpdateQueue move-only. r=sotaro
gfx/webrender_bindings/WebRenderAPI.cpp
gfx/webrender_bindings/WebRenderAPI.h
--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -430,19 +430,35 @@ WebRenderAPI::UpdateResources(ResourceUp
   wr_api_update_resources(mDocHandle, aUpdates.Raw());
 }
 
 ResourceUpdateQueue::ResourceUpdateQueue()
 {
   mUpdates = wr_resource_updates_new();
 }
 
+ResourceUpdateQueue::ResourceUpdateQueue(ResourceUpdateQueue&& aFrom)
+{
+  mUpdates = aFrom.mUpdates;
+  aFrom.mUpdates = nullptr;
+}
+
+ResourceUpdateQueue&
+ResourceUpdateQueue::operator=(ResourceUpdateQueue&& aFrom)
+{
+  mUpdates = aFrom.mUpdates;
+  aFrom.mUpdates = nullptr;
+  return *this;
+}
+
 ResourceUpdateQueue::~ResourceUpdateQueue()
 {
-  wr_resource_updates_delete(mUpdates);
+  if (mUpdates) {
+    wr_resource_updates_delete(mUpdates);
+  }
 }
 
 void
 ResourceUpdateQueue::AddImage(ImageKey key, const ImageDescriptor& aDescriptor,
                               Range<uint8_t> aBytes)
 {
   wr_resource_updates_add_image(mUpdates,
                                 key,
--- a/gfx/webrender_bindings/WebRenderAPI.h
+++ b/gfx/webrender_bindings/WebRenderAPI.h
@@ -48,18 +48,21 @@ struct Line {
   wr::LineStyle style;
 };
 
 /// Updates to retained resources such as images and fonts, applied within the
 /// same transaction.
 class ResourceUpdateQueue {
 public:
   ResourceUpdateQueue();
-
   ~ResourceUpdateQueue();
+  ResourceUpdateQueue(ResourceUpdateQueue&&);
+  ResourceUpdateQueue(const ResourceUpdateQueue&) = delete;
+  ResourceUpdateQueue& operator=(ResourceUpdateQueue&&);
+  ResourceUpdateQueue& operator=(const ResourceUpdateQueue&) = delete;
 
   void AddImage(wr::ImageKey aKey,
                 const ImageDescriptor& aDescriptor,
                 Range<uint8_t> aBytes);
 
   void AddBlobImage(wr::ImageKey aKey,
                     const ImageDescriptor& aDescriptor,
                     Range<uint8_t> aBytes);