Backed out 4 changesets (bug 1858627) for causing clipboard/paste failures. CLOSED...
[gecko.git] / dom / canvas / ImageUtils.h
blob6b9cd9ca7148fee6cd12d15910caba51146e7920
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_ImageBitmapFormatUtils_h
8 #define mozilla_dom_ImageBitmapFormatUtils_h
10 #include <cstdint>
12 #include "nsTArrayForwardDeclare.h"
14 namespace mozilla {
16 template <typename T>
17 class Maybe;
19 namespace layers {
20 class Image;
23 class ErrorResult;
25 namespace dom {
27 struct ChannelPixelLayout;
28 enum class ImageBitmapFormat : uint8_t;
30 typedef nsTArray<ChannelPixelLayout> ImagePixelLayout;
33 * ImageUtils is a wrapper around layers::Image. It provides three unified
34 * methods to all sub-classes of layers::Image, which are:
36 * (1) GetFormat() converts the image's format into ImageBitmapFormat enum.
37 * (2) GetBufferLength() returns the number of bytes that are used to store
38 * the image's underlying raw data.
40 * In theory, the functionalities of this class could be merged into the
41 * interface of layers::Image. However, this is designed as a isolated wrapper
42 * because we don't want to pollute the layers::Image's interface with methods
43 * that are only meaningful to the ImageBitmap.
45 class ImageUtils {
46 public:
47 class Impl;
48 ImageUtils() = delete;
49 ImageUtils(const ImageUtils&) = delete;
50 ImageUtils(ImageUtils&&) = delete;
51 ImageUtils& operator=(const ImageUtils&) = delete;
52 ImageUtils& operator=(ImageUtils&&) = delete;
54 explicit ImageUtils(layers::Image* aImage);
55 ~ImageUtils();
57 Maybe<ImageBitmapFormat> GetFormat() const;
59 uint32_t GetBufferLength() const;
61 protected:
62 Impl* mImpl;
65 } // namespace dom
66 } // namespace mozilla
68 #endif /* mozilla_dom_ImageBitmapFormatUtils_h */