Bug 1584375. Remove unused origin from recording. r=nical
authorJeff Muizelaar <jrmuizel@gmail.com>
Wed, 02 Oct 2019 21:47:11 +0000
changeset 496110 3040cb6328c3648532e92b9151de0a216252192c
parent 496109 bd88f466b13aca5f160c1be15c22a17fe5dbb3aa
child 496111 83b9448bbfafc3dcec439577045c0fd8cee83633
push id114141
push userrmaries@mozilla.com
push dateThu, 03 Oct 2019 09:42:28 +0000
treeherdermozilla-inbound@4a20e73bd624 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1584375
milestone71.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 1584375. Remove unused origin from recording. r=nical This was added as part of an intermediate step to blob recoordination. It's not used anymore. Differential Revision: https://phabricator.services.mozilla.com/D47354
gfx/2d/DrawEventRecorder.cpp
gfx/2d/DrawEventRecorder.h
gfx/layers/wr/WebRenderCommandBuilder.cpp
gfx/layers/wr/WebRenderDrawEventRecorder.h
gfx/webrender_bindings/Moz2DImageRenderer.cpp
gfx/webrender_bindings/src/moz2d_renderer.rs
--- a/gfx/2d/DrawEventRecorder.cpp
+++ b/gfx/2d/DrawEventRecorder.cpp
@@ -85,18 +85,18 @@ void DrawEventRecorderFile::Close() {
   mOutputStream.close();
 }
 
 DrawEventRecorderMemory::DrawEventRecorderMemory() {
   WriteHeader(mOutputStream);
 }
 
 DrawEventRecorderMemory::DrawEventRecorderMemory(
-    const SerializeResourcesFn& aFn, IntPoint aOrigin)
-    : mSerializeCallback(aFn), mOrigin(aOrigin) {
+    const SerializeResourcesFn& aFn)
+    : mSerializeCallback(aFn) {
   mExternalFonts = !!mSerializeCallback;
   WriteHeader(mOutputStream);
 }
 
 void DrawEventRecorderMemory::Flush() {}
 
 void DrawEventRecorderMemory::FlushItem(IntRect aRect) {
   MOZ_RELEASE_ASSERT(!aRect.IsEmpty());
@@ -127,17 +127,16 @@ bool DrawEventRecorderMemory::Finish() {
   // for example if there are no items in a particular area
   size_t indexOffset = mOutputStream.mLength;
   // write out the index
   mOutputStream.write(mIndex.mData, mIndex.mLength);
   bool hasItems = mIndex.mLength != 0;
   mIndex = MemStream();
   // write out the offset of the Index to the end of the output stream
   WriteElement(mOutputStream, indexOffset);
-  WriteElement(mOutputStream, mOrigin);
   ClearResources();
   return hasItems;
 }
 
 size_t DrawEventRecorderMemory::RecordingSize() {
   return mOutputStream.mLength;
 }
 
--- a/gfx/2d/DrawEventRecorder.h
+++ b/gfx/2d/DrawEventRecorder.h
@@ -174,18 +174,17 @@ typedef std::function<void(MemStream& aS
 class DrawEventRecorderMemory : public DrawEventRecorderPrivate {
  public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DrawEventRecorderMemory, override)
 
   /**
    * Constructs a DrawEventRecorder that stores the recording in memory.
    */
   DrawEventRecorderMemory();
-  explicit DrawEventRecorderMemory(const SerializeResourcesFn& aSerialize,
-                                   IntPoint aOrigin = IntPoint());
+  explicit DrawEventRecorderMemory(const SerializeResourcesFn& aSerialize);
 
   void RecordEvent(const RecordedEvent& aEvent) override;
 
   void AddDependentSurface(uint64_t aDependencyId) override;
 
   nsTHashtable<nsUint64HashKey>&& TakeDependentSurfaces();
 
   /**
@@ -212,17 +211,16 @@ class DrawEventRecorderMemory : public D
   MemStream mIndex;
 
  protected:
   virtual ~DrawEventRecorderMemory(){};
 
  private:
   SerializeResourcesFn mSerializeCallback;
   nsTHashtable<nsUint64HashKey> mDependentSurfaces;
-  IntPoint mOrigin;
 
   void Flush() override;
 };
 
 }  // namespace gfx
 }  // namespace mozilla
 
 #endif /* MOZILLA_GFX_DRAWEVENTRECORDER_H_ */
--- a/gfx/layers/wr/WebRenderCommandBuilder.cpp
+++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp
@@ -654,18 +654,17 @@ struct DIGroup {
                 if (key.isNothing()) {
                   validFonts = false;
                   break;
                 }
                 BlobFont font = {key.value(), scaled};
                 aStream.write((const char*)&font, sizeof(font));
               }
               fonts = std::move(aScaledFonts);
-            },
-            mVisibleRect.ToUnknownRect().TopLeft());
+            });
 
     RefPtr<gfx::DrawTarget> dummyDt = gfx::Factory::CreateDrawTarget(
         gfx::BackendType::SKIA, gfx::IntSize(1, 1), format);
 
     RefPtr<gfx::DrawTarget> dt = gfx::Factory::CreateRecordingDrawTarget(
         recorder, dummyDt, mLayerBounds.ToUnknownRect());
     // Setup the gfxContext
     RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
@@ -2254,18 +2253,17 @@ WebRenderCommandBuilder::GenerateFallbac
                   if (key.isNothing()) {
                     validFonts = false;
                     break;
                   }
                   BlobFont font = {key.value(), scaled};
                   aStream.write((const char*)&font, sizeof(font));
                 }
                 fonts = std::move(aScaledFonts);
-              },
-              visibleRect.ToUnknownRect().TopLeft());
+              });
       RefPtr<gfx::DrawTarget> dummyDt = gfx::Factory::CreateDrawTarget(
           gfx::BackendType::SKIA, gfx::IntSize(1, 1), format);
       RefPtr<gfx::DrawTarget> dt = gfx::Factory::CreateRecordingDrawTarget(
           recorder, dummyDt, visibleRect.ToUnknownRect());
       if (!fallbackData->mBasicLayerManager) {
         fallbackData->mBasicLayerManager =
             new BasicLayerManager(BasicLayerManager::BLM_INACTIVE);
       }
@@ -2486,18 +2484,17 @@ Maybe<wr::ImageMask> WebRenderCommandBui
                   validFonts = false;
                   break;
                 }
                 BlobFont font = {key.value(), scaled};
                 aStream.write((const char*)&font, sizeof(font));
               }
 
               fonts = std::move(aScaledFonts);
-            },
-            IntPoint(0, 0));
+            });
 
     RefPtr<DrawTarget> dummyDt = Factory::CreateDrawTarget(
         BackendType::SKIA, IntSize(1, 1), SurfaceFormat::A8);
     RefPtr<DrawTarget> dt = Factory::CreateRecordingDrawTarget(
         recorder, dummyDt, IntRect(IntPoint(0, 0), size));
 
     RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
     MOZ_ASSERT(context);
--- a/gfx/layers/wr/WebRenderDrawEventRecorder.h
+++ b/gfx/layers/wr/WebRenderDrawEventRecorder.h
@@ -4,33 +4,32 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZILLA_LAYERS_WEBRENDERDRAWTARGETRECORDER_H
 #define MOZILLA_LAYERS_WEBRENDERDRAWTARGETRECORDER_H
 
 #include "mozilla/gfx/DrawEventRecorder.h"
 #include "mozilla/gfx/InlineTranslator.h"
 #include "mozilla/webrender/webrender_ffi.h"
-#include "mozilla/gfx/Point.h"
 
 namespace mozilla {
 namespace layers {
 
 struct BlobFont {
   wr::FontInstanceKey mFontInstanceKey;
   gfx::ReferencePtr mScaledFontPtr;
 };
 
 class WebRenderDrawEventRecorder final : public gfx::DrawEventRecorderMemory {
  public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(WebRenderDrawEventRecorder, final)
 
   explicit WebRenderDrawEventRecorder(
-      const gfx::SerializeResourcesFn& aSerialize, gfx::IntPoint aOrigin)
-      : DrawEventRecorderMemory(aSerialize, aOrigin) {}
+      const gfx::SerializeResourcesFn& aSerialize)
+      : DrawEventRecorderMemory(aSerialize) {}
 
   void StoreSourceSurfaceRecording(gfx::SourceSurface* aSurface,
                                    const char* aReason) final;
 
  private:
   virtual ~WebRenderDrawEventRecorder() = default;
 };
 
--- a/gfx/webrender_bindings/Moz2DImageRenderer.cpp
+++ b/gfx/webrender_bindings/Moz2DImageRenderer.cpp
@@ -362,17 +362,17 @@ static bool Moz2DRenderCallback(const Ra
       uninitialized);
 
   if (!dt) {
     return false;
   }
 
   // We try hard to not have empty blobs but we can end up with
   // them because of CompositorHitTestInfo and merging.
-  size_t footerSize = sizeof(size_t) + sizeof(IntPoint);
+  size_t footerSize = sizeof(size_t);
   MOZ_RELEASE_ASSERT(aBlob.length() >= footerSize);
   size_t indexOffset = ConvertFromBytes<size_t>(aBlob.end().get() - footerSize);
 
   // aRenderRect is the part of the blob that we are currently rendering
   // (for example a tile) in the same coordinate space as aVisibleRect.
   IntPoint origin = gfx::IntPoint(aRenderRect->origin.x, aRenderRect->origin.y);
 
   MOZ_RELEASE_ASSERT(indexOffset <= aBlob.length() - footerSize);
--- a/gfx/webrender_bindings/src/moz2d_renderer.rs
+++ b/gfx/webrender_bindings/src/moz2d_renderer.rs
@@ -167,17 +167,16 @@ impl<'a> BufReader<'a> {
 ///  the data Vec
 ///  - we use indices/offsets instead of sizes to avoid having to deal with any
 ///  arithmetic that might overflow.
 struct BlobReader<'a> {
     /// The buffer of the blob.
     reader: BufReader<'a>,
     /// Where the buffer head is.
     begin: usize,
-    origin: IntPoint,
 }
 
 #[derive(PartialEq, Debug, Eq, Clone, Copy)]
 struct IntPoint {
     x: i32,
     y: i32
 }
 
@@ -195,22 +194,21 @@ struct Entry {
     /// Where the item's extra data ends, and the next item's `begin`.
     extra_end: usize,
 }
 
 impl<'a> BlobReader<'a> {
     /// Creates a new BlobReader for the given buffer.
     fn new(buf: &'a[u8]) -> BlobReader<'a> {
         // The offset of the index is at the end of the buffer.
-        let index_offset_pos = buf.len()-(mem::size_of::<usize>() + mem::size_of::<IntPoint>());
+        let index_offset_pos = buf.len()-mem::size_of::<usize>();
         assert!(index_offset_pos < buf.len());
         let index_offset = unsafe { convert_from_bytes::<usize>(&buf[index_offset_pos..]) };
-        let origin = unsafe { convert_from_bytes(&buf[(index_offset_pos + mem::size_of::<usize>())..]) };
 
-        BlobReader { reader: BufReader::new(&buf[index_offset..index_offset_pos]), begin: 0, origin }
+        BlobReader { reader: BufReader::new(&buf[index_offset..index_offset_pos]), begin: 0}
     }
 
     /// Reads the next display item's metadata.
     fn read_entry(&mut self) -> Entry {
         let end = self.reader.read_usize();
         let extra_end = self.reader.read_usize();
         let bounds = self.reader.read_box();
         let ret = Entry { begin: self.begin, end, extra_end, bounds };
@@ -246,23 +244,22 @@ impl BlobWriter {
         // Write the bounds to the index.
         self.index.extend_from_slice(convert_to_bytes(&bounds.x1));
         self.index.extend_from_slice(convert_to_bytes(&bounds.y1));
         self.index.extend_from_slice(convert_to_bytes(&bounds.x2));
         self.index.extend_from_slice(convert_to_bytes(&bounds.y2));
     }
 
     /// Completes the blob image, producing a single buffer containing it.
-    fn finish(mut self, origin: IntPoint) -> Vec<u8> {
+    fn finish(mut self) -> Vec<u8> {
         // Append the index to the end of the buffer
         // and then append the offset to the beginning of the index.
         let index_begin = self.data.len();
         self.data.extend_from_slice(&self.index);
         self.data.extend_from_slice(convert_to_bytes(&index_begin));
-        self.data.extend_from_slice(convert_to_bytes(&origin));
         self.data
     }
 }
 
 #[derive(Debug, Eq, PartialEq, Clone, Copy, Ord, PartialOrd)]
 #[repr(C)]
 /// A two-points representation of a rectangle.
 struct Box2d {
@@ -456,17 +453,17 @@ fn merge_blob_images(old_buf: &[u8], new
     while old_reader.reader.reader.has_more() {
         let old = old_reader.reader.read_entry();
         dlog!("new bounds: {} {} {:?}", old.end, old.extra_end, old.bounds);
         //assert!(old.bounds.contained_by(&dirty_rect));
     }
 
     //assert!(old_reader.cache.is_empty());
 
-    let result = result.finish(new_reader.origin);
+    let result = result.finish();
     dump_index(&result);
     result
 }
 
 /// A font used by a blob image.
 #[repr(C)]
 #[derive(Copy, Clone)]
 struct BlobFont {