Bug 1480608. Skip over items that aren't in DrawTarget/DirtyRect. r=mstange

MozReview-Commit-ID: Kc9E1SUVUh3

--HG--
extra : rebase_source : d3ee33154622915bd444139bce639e4372fe8f43
This commit is contained in:
Jeff Muizelaar 2018-08-02 18:09:17 -04:00
Родитель e2bdc2a3f4
Коммит 955d35ed01
2 изменённых файлов: 26 добавлений и 4 удалений

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

@ -94,6 +94,10 @@ public:
return result;
}
bool IsEmpty() const {
return right <= left || bottom <= top;
}
bool IsEqualEdges(const Sub& aOther) const
{
return left == aOther.left && top == aOther.top &&

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

@ -8,6 +8,7 @@
#include "mozilla/Mutex.h"
#include "mozilla/Range.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/RectAbsolute.h"
#include "mozilla/gfx/Logging.h"
#include "mozilla/gfx/RecordedEvent.h"
#include "mozilla/layers/WebRenderDrawEventRecorder.h"
@ -261,9 +262,15 @@ static bool Moz2DRenderCallback(const Range<const uint8_t> aBlob,
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 {
@ -288,9 +295,15 @@ static bool Moz2DRenderCallback(const Range<const uint8_t> aBlob,
return ret;
}
void SkipBounds() {
MOZ_RELEASE_ASSERT(pos + sizeof(int) * 4 <= len);
pos += sizeof(int) * 4;
IntRectAbsolute ReadBounds() {
MOZ_RELEASE_ASSERT(pos + sizeof(int32_t) * 4 <= len);
int32_t x1, y1, x2, y2;
memcpy(&x1, buf + pos + 0 * sizeof(int32_t), sizeof(x1));
memcpy(&y1, buf + pos + 1 * sizeof(int32_t), sizeof(y1));
memcpy(&x2, buf + pos + 2 * sizeof(int32_t), sizeof(x2));
memcpy(&y2, buf + pos + 3 * sizeof(int32_t), sizeof(y2));
pos += sizeof(int32_t) * 4;
return IntRectAbsolute(x1, y1, x2, y2);
}
};
@ -300,10 +313,15 @@ static bool Moz2DRenderCallback(const Range<const uint8_t> aBlob,
bool ret;
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();
reader.SkipBounds();
auto combinedBounds = absBounds.Intersect(reader.ReadBounds());
if (combinedBounds.IsEmpty()) {
offset = extra_end;
continue;
}
layers::WebRenderTranslator translator(dt);