Backed out changeset cb1d78b00e25 (bug 1563775) on request from jrmuizel for causing Bug 1565231. a=backout

This commit is contained in:
Brindusan Cristian 2019-07-11 17:40:51 +03:00
Родитель 15be167a5b
Коммит fd86c6d641
6 изменённых файлов: 39 добавлений и 66 удалений

Просмотреть файл

@ -92,8 +92,8 @@ DrawEventRecorderMemory::DrawEventRecorderMemory() {
}
DrawEventRecorderMemory::DrawEventRecorderMemory(
const SerializeResourcesFn& aFn, IntPoint aOrigin)
: mSerializeCallback(aFn), mOrigin(aOrigin) {
const SerializeResourcesFn& aFn)
: mSerializeCallback(aFn) {
mExternalFonts = !!mSerializeCallback;
WriteHeader(mOutputStream);
}
@ -134,7 +134,6 @@ bool DrawEventRecorderMemory::Finish() {
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;
}

Просмотреть файл

@ -179,8 +179,7 @@ class DrawEventRecorderMemory : public DrawEventRecorderPrivate {
* 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;
@ -217,7 +216,6 @@ class DrawEventRecorderMemory : public DrawEventRecorderPrivate {
private:
SerializeResourcesFn mSerializeCallback;
nsTHashtable<nsUint64HashKey> mDependentSurfaces;
IntPoint mOrigin;
void Flush() override;
};

Просмотреть файл

@ -671,8 +671,7 @@ struct DIGroup {
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);
@ -1343,11 +1342,11 @@ void Grouper::ConstructItemInsideInactive(
// 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);
@ -2276,8 +2275,7 @@ WebRenderCommandBuilder::GenerateFallbackData(
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(
@ -2499,8 +2497,7 @@ Maybe<wr::ImageMask> WebRenderCommandBuilder::BuildWrMaskImage(
}
fonts = std::move(aScaledFonts);
},
IntPoint(0, 0));
});
RefPtr<DrawTarget> dummyDt = Factory::CreateDrawTarget(
BackendType::SKIA, IntSize(1, 1), SurfaceFormat::A8);

Просмотреть файл

@ -9,7 +9,6 @@
#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 {
@ -24,8 +23,8 @@ class WebRenderDrawEventRecorder final : public gfx::DrawEventRecorderMemory {
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;

Просмотреть файл

@ -335,6 +335,24 @@ static bool Moz2DRenderCallback(const Range<const uint8_t> aBlob,
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;
@ -379,35 +397,11 @@ static bool Moz2DRenderCallback(const Range<const uint8_t> aBlob,
// 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;

Просмотреть файл

@ -172,16 +172,8 @@ struct BlobReader<'a> {
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.
@ -200,12 +192,10 @@ 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.
@ -251,13 +241,12 @@ impl BlobWriter {
}
/// 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
}
}
@ -393,9 +382,6 @@ fn merge_blob_images(old_buf: &[u8], new_buf: &[u8], dirty_rect: Box2d) -> Vec<u
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
@ -426,7 +412,7 @@ fn merge_blob_images(old_buf: &[u8], new_buf: &[u8], dirty_rect: Box2d) -> Vec<u
assert!(old_reader.cache.is_empty());
let result = result.finish(new_reader.origin);
let result = result.finish();
dump_index(&result);
result
}