Skip to content

Commit

Permalink
Bug 1368776 - Part 15. Cache flags passed to ImageResource::GetImageC…
Browse files Browse the repository at this point in the history
…ontainerImpl for consistency. r=tnikkel

When FLAG_HIGH_QUALITY_SCALING is used, we need to make sure we continue
using that flag when we update the container. We should also use it for
comparing whether or not an existing image container is equivalent.
  • Loading branch information
aosmond committed Nov 17, 2017
1 parent addb00a commit 0cfb7cd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 6 additions & 4 deletions image/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,15 @@ ImageResource::GetImageContainerImpl(LayerManager* aManager,
SendOnUnlockedDraw(aFlags);
}

uint32_t flags = (aFlags & ~(FLAG_SYNC_DECODE |
FLAG_SYNC_DECODE_IF_FAST)) | FLAG_ASYNC_NOTIFY;
RefPtr<layers::ImageContainer> container;
ImageContainerEntry* entry = nullptr;
int i = mImageContainers.Length() - 1;
for (; i >= 0; --i) {
entry = &mImageContainers[i];
container = entry->mContainer.get();
if (size == entry->mSize) {
if (size == entry->mSize && flags == entry->mFlags) {
// Lack of a container is handled below.
break;
} else if (!container) {
Expand Down Expand Up @@ -179,7 +181,7 @@ ImageResource::GetImageContainerImpl(LayerManager* aManager,
i = mImageContainers.Length() - 1;
for (; i >= 0; --i) {
entry = &mImageContainers[i];
if (bestSize == entry->mSize) {
if (bestSize == entry->mSize && flags == entry->mFlags) {
container = entry->mContainer.get();
if (container) {
switch (entry->mLastDrawResult) {
Expand Down Expand Up @@ -213,7 +215,7 @@ ImageResource::GetImageContainerImpl(LayerManager* aManager,
entry->mContainer = container;
} else {
entry = mImageContainers.AppendElement(
ImageContainerEntry(bestSize, container.get()));
ImageContainerEntry(bestSize, container.get(), flags));
}
}

Expand All @@ -234,7 +236,7 @@ ImageResource::UpdateImageContainer()
IntSize bestSize;
RefPtr<SourceSurface> surface;
Tie(entry.mLastDrawResult, bestSize, surface) =
GetFrameInternal(entry.mSize, FRAME_CURRENT, FLAG_ASYNC_NOTIFY);
GetFrameInternal(entry.mSize, FRAME_CURRENT, entry.mFlags);

// It is possible that this is a factor-of-2 substitution. Since we
// managed to convert the weak reference into a strong reference, that
Expand Down
7 changes: 6 additions & 1 deletion image/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,12 @@ class ImageResource : public Image

struct ImageContainerEntry {
ImageContainerEntry(const gfx::IntSize& aSize,
layers::ImageContainer* aContainer)
layers::ImageContainer* aContainer,
uint32_t aFlags)
: mSize(aSize)
, mContainer(aContainer)
, mLastDrawResult(DrawResult::NOT_READY)
, mFlags(aFlags)
{ }

gfx::IntSize mSize;
Expand All @@ -388,6 +390,9 @@ class ImageResource : public Image
// If mContainer is non-null, this contains the DrawResult we obtained
// the last time we updated it.
DrawResult mLastDrawResult;
// Cached flags to use for decoding. FLAG_ASYNC_NOTIFY should always be set
// but FLAG_HIGH_QUALITY_SCALING may vary.
uint32_t mFlags;
};

AutoTArray<ImageContainerEntry, 1> mImageContainers;
Expand Down

0 comments on commit 0cfb7cd

Please sign in to comment.