Backed out changeset cb1d78b00e25 (bug 1563775) on request from jrmuizel for causing Bug 1565231. a=backout
authorBrindusan Cristian <cbrindusan@mozilla.com>
Thu, 11 Jul 2019 17:40:51 +0300
changeset 482384 a39b925a26ade6f6d05c51dde62764b149043a00
parent 482324 0c076622290967834426f37e4e557f1f475c7250
child 482385 8013e87c08ac8b3a8d6912936f594a8219170b1e
push id113664
push usercbrindusan@mozilla.com
push dateThu, 11 Jul 2019 16:24:25 +0000
treeherdermozilla-inbound@4b059a36d377 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1563775, 1565231
milestone70.0a1
backs outcb1d78b00e25dd7fcfec86216c7a83c85ce9a982
first release with
nightly linux32
a39b925a26ad / 70.0a1 / 20190711144155 / files
nightly linux64
a39b925a26ad / 70.0a1 / 20190711144155 / files
nightly mac
a39b925a26ad / 70.0a1 / 20190711144155 / files
nightly win32
a39b925a26ad / 70.0a1 / 20190711144155 / files
nightly win64
a39b925a26ad / 70.0a1 / 20190711144155 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset cb1d78b00e25 (bug 1563775) on request from jrmuizel for causing Bug 1565231. a=backout
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
@@ -87,18 +87,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());
@@ -129,17 +129,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
@@ -666,18 +666,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);
-            },
-            IntPoint(0, 0));
+            });
 
     RefPtr<gfx::DrawTarget> dummyDt = gfx::Factory::CreateDrawTarget(
         gfx::BackendType::SKIA, gfx::IntSize(1, 1), format);
 
     RefPtr<gfx::DrawTarget> dt =
         gfx::Factory::CreateRecordingDrawTarget(recorder, dummyDt, IntRect(IntPoint(0, 0), dtSize));
     // Setup the gfxContext
     RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
@@ -1338,21 +1337,21 @@ void Grouper::ConstructItemInsideInactiv
    * set it to 'true' we ensure that we're not using the value from the last
    * time that we painted */
   data->mInvalid = false;
 
   // we compute the geometry change here because we have the transform around
   // still
   aGroup->ComputeGeometryChange(aItem, data, mTransform, mDisplayListBuilder);
 
-  // Temporarily restrict the image bounds to the bounds of the container so
-  // that clipped children within the container know about the clip. This
-  // ensures that the bounds passed to FlushItem are contained in the bounds of
-  // the clip so that we don't include items in the recording without including
-  // their corresponding clipping items.
+  // Temporarily restrict the image bounds to the bounds of the container so that
+  // clipped children within the container know about the clip. This ensures
+  // that the bounds passed to FlushItem are contained in the bounds of the clip
+  // so that we don't include items in the recording without including their
+  // corresponding clipping items.
   IntRect oldClippedImageBounds = aGroup->mClippedImageBounds;
   aGroup->mClippedImageBounds =
       aGroup->mClippedImageBounds.Intersect(data->mRect);
 
   if (aItem->GetType() == DisplayItemType::TYPE_FILTER) {
     gfx::Size scale(1, 1);
     // If ComputeDifferences finds any change, we invalidate the entire
     // container item. This is needed because blob merging requires the entire
@@ -2271,18 +2270,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);
-              },
-              IntPoint(0, 0));
+              });
       RefPtr<gfx::DrawTarget> dummyDt = gfx::Factory::CreateDrawTarget(
           gfx::BackendType::SKIA, gfx::IntSize(1, 1), format);
       RefPtr<gfx::DrawTarget> dt = gfx::Factory::CreateRecordingDrawTarget(
           recorder, dummyDt, IntRect(IntPoint(0, 0), dtSize.ToUnknownSize()));
       if (!fallbackData->mBasicLayerManager) {
         fallbackData->mBasicLayerManager =
             new BasicLayerManager(BasicLayerManager::BLM_INACTIVE);
       }
@@ -2494,18 +2492,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
@@ -330,16 +330,34 @@ static bool Moz2DRenderCallback(const Ra
   RefPtr<gfx::DrawTarget> dt = gfx::Factory::CreateDrawTargetForData(
       gfx::BackendType::SKIA, aOutput.begin().get(), aSize, stride, aFormat,
       uninitialized);
 
   if (!dt) {
     return false;
   }
 
+  auto origin = gfx::IntPoint(0, 0);
+  if (aTileOffset) {
+    origin =
+        gfx::IntPoint(aTileOffset->x * *aTileSize, aTileOffset->y * *aTileSize);
+    dt = gfx::Factory::CreateOffsetDrawTarget(dt, origin);
+  }
+
+  auto bounds = gfx::IntRect(origin, aSize);
+
+  if (aDirtyRect) {
+    Rect dirty(aDirtyRect->origin.x, aDirtyRect->origin.y,
+               aDirtyRect->size.width, aDirtyRect->size.height);
+    dt->PushClipRect(dirty);
+    bounds = bounds.Intersect(
+        IntRect(aDirtyRect->origin.x, aDirtyRect->origin.y,
+                aDirtyRect->size.width, aDirtyRect->size.height));
+  }
+
   struct Reader {
     const uint8_t* buf;
     size_t len;
     size_t pos;
 
     Reader(const uint8_t* buf, size_t len) : buf(buf), len(len), pos(0) {}
 
     size_t ReadSize() {
@@ -374,45 +392,21 @@ static bool Moz2DRenderCallback(const Ra
       memcpy(&ret, buf + pos, sizeof(ret));
       pos += sizeof(ret);
       return ret;
     }
   };
 
   // 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);
-  MOZ_RELEASE_ASSERT(aBlob.length() >= footerSize);
-  size_t indexOffset = *(size_t*)(aBlob.end().get() - footerSize);
-  IntPoint recordingOrigin =
-      *(IntPoint*)(aBlob.end().get() - footerSize + sizeof(size_t));
-  // Apply the visibleRect's offset to make (0, 0) in the DT correspond to (0,
-  // 0) in the texture
-
-  MOZ_RELEASE_ASSERT(indexOffset <= aBlob.length() - footerSize);
+  MOZ_RELEASE_ASSERT(aBlob.length() >= sizeof(size_t));
+  size_t indexOffset = *(size_t*)(aBlob.end().get() - sizeof(size_t));
+  MOZ_RELEASE_ASSERT(indexOffset <= aBlob.length() - sizeof(size_t));
   Reader reader(aBlob.begin().get() + indexOffset,
-                aBlob.length() - footerSize - indexOffset);
-
-  IntPoint origin;
-  if (aTileOffset) {
-    origin +=
-        gfx::IntPoint(aTileOffset->x * *aTileSize, aTileOffset->y * *aTileSize);
-  }
-  dt = gfx::Factory::CreateOffsetDrawTarget(dt, recordingOrigin + origin);
-
-  auto bounds = gfx::IntRect(origin, aSize);
-
-  if (aDirtyRect) {
-    Rect dirty(aDirtyRect->origin.x, aDirtyRect->origin.y,
-               aDirtyRect->size.width, aDirtyRect->size.height);
-    dt->PushClipRect(dirty);
-    bounds = bounds.Intersect(
-        IntRect(aDirtyRect->origin.x, aDirtyRect->origin.y,
-                aDirtyRect->size.width, aDirtyRect->size.height));
-  }
+                aBlob.length() - sizeof(size_t) - indexOffset);
 
   bool ret = true;
   size_t offset = 0;
   auto absBounds = IntRectAbsolute::FromRect(bounds);
   while (reader.pos < reader.len) {
     size_t end = reader.ReadSize();
     size_t extra_end = reader.ReadSize();
     MOZ_RELEASE_ASSERT(extra_end >= end);
--- a/gfx/webrender_bindings/src/moz2d_renderer.rs
+++ b/gfx/webrender_bindings/src/moz2d_renderer.rs
@@ -167,26 +167,18 @@ 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
-}
-
-
 /// The metadata for each display item in a blob image (doesn't match the serialized layout).
 ///
 /// See BlobReader above for detailed docs of the blob image format.
 struct Entry {
     /// The bounds of the display item.
     bounds: Box2d,
     /// Where the item's recorded drawing commands start.
     begin: usize,
@@ -195,22 +187,20 @@ 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>());
-        assert!(index_offset_pos < buf.len());
+        let index_offset_pos = buf.len()-mem::size_of::<usize>();
         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 +236,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 {
@@ -388,19 +377,16 @@ fn merge_blob_images(old_buf: &[u8], new
     dlog!("old:");
     dump_bounds(old_buf, dirty_rect);
     dlog!("new:");
     dump_bounds(new_buf, dirty_rect);
 
     let mut old_reader = CachedReader::new(old_buf);
     let mut new_reader = BlobReader::new(new_buf);
 
-    // we currently only support merging blobs that have the same origin
-    assert_eq!(old_reader.reader.origin, new_reader.origin);
-
     // Loop over both new and old entries merging them.
     // Both new and old must have the same number of entries that
     // overlap but are not contained by the dirty rect, and they
     // must be in the same order.
     while new_reader.reader.has_more() {
         let new = new_reader.read_entry();
         dlog!("bounds: {} {} {:?}", new.end, new.extra_end, new.bounds);
         if new.bounds.contained_by(&dirty_rect) {
@@ -421,17 +407,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)]
 struct BlobFont {
     /// The font key.