Bug 1856663 - Add more chunks for Android mochitest-plain. r=jmaher,taskgraph-reviewe...
[gecko.git] / layout / base / SurfaceFromElementResult.h
blob4b889609e6c6b2fd30f3061816f6be48628ef2b3
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
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_SurfaceFromElementResult_h
8 #define mozilla_SurfaceFromElementResult_h
10 #include "ImageContainer.h"
11 #include "gfxTypes.h"
12 #include "mozilla/gfx/Point.h"
13 #include "nsCOMPtr.h"
14 #include <cstdint>
16 class imgIContainer;
17 class imgIRequest;
18 class nsIPrincipal;
19 class nsLayoutUtils;
21 namespace mozilla {
23 namespace dom {
24 class CanvasRenderingContext2D;
25 class ImageBitmap;
26 } // namespace dom
28 namespace gfx {
29 class SourceSurface;
32 struct DirectDrawInfo {
33 /* imgIContainer to directly draw to a context */
34 nsCOMPtr<imgIContainer> mImgContainer;
35 /* which frame to draw */
36 uint32_t mWhichFrame;
37 /* imgIContainer flags to use when drawing */
38 uint32_t mDrawingFlags;
41 struct SurfaceFromElementResult {
42 friend class mozilla::dom::CanvasRenderingContext2D;
43 friend class mozilla::dom::ImageBitmap;
44 friend class ::nsLayoutUtils;
46 /* If SFEResult contains a valid surface, it either mLayersImage or
47 * mSourceSurface will be non-null, and GetSourceSurface() will not be null.
49 * For valid surfaces, mSourceSurface may be null if mLayersImage is
50 * non-null, but GetSourceSurface() will create mSourceSurface from
51 * mLayersImage when called.
54 /* Video elements (at least) often are already decoded as layers::Images. */
55 RefPtr<mozilla::layers::Image> mLayersImage;
57 protected:
58 /* GetSourceSurface() fills this and returns its non-null value if this
59 * SFEResult was successful. */
60 RefPtr<mozilla::gfx::SourceSurface> mSourceSurface;
62 public:
63 /* Contains info for drawing when there is no mSourceSurface. */
64 DirectDrawInfo mDrawInfo;
66 /* The size of the surface */
67 mozilla::gfx::IntSize mSize;
68 /* The size the surface is intended to be rendered at */
69 mozilla::gfx::IntSize mIntrinsicSize;
70 /* The crop rect of the surface, indicating what subset is valid. This will
71 * always be Nothing() unless SFE_ALLOW_UNCROPPED is set. */
72 mozilla::Maybe<mozilla::gfx::IntRect> mCropRect;
73 /* The principal associated with the element whose surface was returned.
74 If there is a surface, this will never be null. */
75 nsCOMPtr<nsIPrincipal> mPrincipal;
76 /* The image request, if the element is an nsIImageLoadingContent */
77 nsCOMPtr<imgIRequest> mImageRequest;
78 /* True if cross-origins redirects have been done in order to load this
79 * resource */
80 bool mHadCrossOriginRedirects;
81 /* Whether the element was "write only", that is, the bits should not be
82 * exposed to content */
83 bool mIsWriteOnly;
84 /* Whether the element was still loading. Some consumers need to handle
85 this case specially. */
86 bool mIsStillLoading;
87 /* Whether the element has a valid size. */
88 bool mHasSize;
89 /* Whether the element used CORS when loading. */
90 bool mCORSUsed;
92 gfxAlphaType mAlphaType;
94 // Methods:
96 SurfaceFromElementResult();
98 // Gets mSourceSurface, or makes a SourceSurface from mLayersImage.
99 const RefPtr<mozilla::gfx::SourceSurface>& GetSourceSurface();
102 } // namespace mozilla
104 #endif // mozilla_SurfaceFromElementResult_h