summaryrefslogtreecommitdiff
path: root/image/SurfaceFlags.h
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /image/SurfaceFlags.h
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloaduxp-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
Add m-esr52 at 52.6.0
Diffstat (limited to 'image/SurfaceFlags.h')
-rw-r--r--image/SurfaceFlags.h73
1 files changed, 73 insertions, 0 deletions
diff --git a/image/SurfaceFlags.h b/image/SurfaceFlags.h
new file mode 100644
index 0000000000..1a0000542f
--- /dev/null
+++ b/image/SurfaceFlags.h
@@ -0,0 +1,73 @@
+/* -*- 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
+};
+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;
+ }
+ 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;
+ }
+ return flags;
+}
+
+} // namespace image
+} // namespace mozilla
+
+#endif // mozilla_image_SurfaceFlags_h