mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
ba2c6dea3f
Now that we no longer have the extra layer of ImageContainers providing a superficial level of caching/reuse of existing blob recordings, we need some way to share recordings. This part adds support to SurfaceCache to store BlobSurfaceProvider objects. This includes the specialized code for invalidating SVG images. In particular this is useful for animated SVG images. In general we want to avoid changing the image key whenever possible so that we avoid reallocating the underlying buffers in the compositor process for the rasterized blob images. We also need to track the ImageIntRegion used by the recording. If a caller only wants a slice of the SVG image, then we need to track this differentiation in our cache entries. At this time, we don't allow substitutes for entries with a region exclusion. Differential Revision: https://phabricator.services.mozilla.com/D126603
79 lines
2.5 KiB
C++
79 lines
2.5 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef mozilla_image_SurfaceFlags_h
|
|
#define mozilla_image_SurfaceFlags_h
|
|
|
|
#include "imgIContainer.h"
|
|
#include "mozilla/TypedEnumBits.h"
|
|
|
|
namespace mozilla {
|
|
namespace image {
|
|
|
|
/**
|
|
* Flags that change the output a decoder generates. Because different
|
|
* combinations of these flags result in logically different surfaces, these
|
|
* flags must be taken into account in SurfaceCache lookups.
|
|
*/
|
|
enum class SurfaceFlags : uint8_t {
|
|
NO_PREMULTIPLY_ALPHA = 1 << 0,
|
|
NO_COLORSPACE_CONVERSION = 1 << 1,
|
|
TO_SRGB_COLORSPACE = 1 << 2,
|
|
RECORD_BLOB = 1 << 3,
|
|
};
|
|
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(SurfaceFlags)
|
|
|
|
/**
|
|
* @return the default set of surface flags.
|
|
*/
|
|
inline SurfaceFlags DefaultSurfaceFlags() { return SurfaceFlags(); }
|
|
|
|
/**
|
|
* Given a set of imgIContainer FLAG_* flags, returns a set of SurfaceFlags with
|
|
* the corresponding flags set.
|
|
*/
|
|
inline SurfaceFlags ToSurfaceFlags(uint32_t aFlags) {
|
|
SurfaceFlags flags = DefaultSurfaceFlags();
|
|
if (aFlags & imgIContainer::FLAG_DECODE_NO_PREMULTIPLY_ALPHA) {
|
|
flags |= SurfaceFlags::NO_PREMULTIPLY_ALPHA;
|
|
}
|
|
if (aFlags & imgIContainer::FLAG_DECODE_NO_COLORSPACE_CONVERSION) {
|
|
flags |= SurfaceFlags::NO_COLORSPACE_CONVERSION;
|
|
}
|
|
if (aFlags & imgIContainer::FLAG_DECODE_TO_SRGB_COLORSPACE) {
|
|
flags |= SurfaceFlags::TO_SRGB_COLORSPACE;
|
|
}
|
|
if (aFlags & imgIContainer::FLAG_RECORD_BLOB) {
|
|
flags |= SurfaceFlags::RECORD_BLOB;
|
|
}
|
|
return flags;
|
|
}
|
|
|
|
/**
|
|
* Given a set of SurfaceFlags, returns a set of imgIContainer FLAG_* flags with
|
|
* the corresponding flags set.
|
|
*/
|
|
inline uint32_t FromSurfaceFlags(SurfaceFlags aFlags) {
|
|
uint32_t flags = imgIContainer::DECODE_FLAGS_DEFAULT;
|
|
if (aFlags & SurfaceFlags::NO_PREMULTIPLY_ALPHA) {
|
|
flags |= imgIContainer::FLAG_DECODE_NO_PREMULTIPLY_ALPHA;
|
|
}
|
|
if (aFlags & SurfaceFlags::NO_COLORSPACE_CONVERSION) {
|
|
flags |= imgIContainer::FLAG_DECODE_NO_COLORSPACE_CONVERSION;
|
|
}
|
|
if (aFlags & SurfaceFlags::TO_SRGB_COLORSPACE) {
|
|
flags |= imgIContainer::FLAG_DECODE_TO_SRGB_COLORSPACE;
|
|
}
|
|
if (aFlags & SurfaceFlags::RECORD_BLOB) {
|
|
flags |= imgIContainer::FLAG_RECORD_BLOB;
|
|
}
|
|
return flags;
|
|
}
|
|
|
|
} // namespace image
|
|
} // namespace mozilla
|
|
|
|
#endif // mozilla_image_SurfaceFlags_h
|