Backed out 9 changesets (bug 1901851, bug 1728331) for causing remote worker crashes...
[gecko.git] / image / WebRenderImageProvider.h
blobaf60bbf357a125fd0bd0b41e7ed34d110b460244
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_IMAGE_WEBRENDERIMAGEPROVIDER_H_
8 #define MOZILLA_IMAGE_WEBRENDERIMAGEPROVIDER_H_
10 #include "nsISupportsImpl.h"
12 namespace mozilla {
13 namespace layers {
14 class RenderRootStateManager;
17 namespace wr {
18 class IpcResourceUpdateQueue;
19 struct ExternalImageId;
20 struct ImageKey;
21 } // namespace wr
23 namespace image {
25 class ImageResource;
26 using ImageProviderId = uint32_t;
28 class WebRenderImageProvider {
29 public:
30 // Subclasses may or may not be XPCOM classes, so we just require that they
31 // implement AddRef and Release.
32 NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
34 ImageProviderId GetProviderId() const { return mProviderId; }
36 static ImageProviderId AllocateProviderId();
38 /**
39 * Generate an ImageKey for the given frame.
40 * @param aSurface The current frame. This should match what was cached via
41 * SetCurrentFrame, but if it does not, it will need to
42 * regenerate the cached ImageKey.
44 virtual nsresult UpdateKey(layers::RenderRootStateManager* aManager,
45 wr::IpcResourceUpdateQueue& aResources,
46 wr::ImageKey& aKey) {
47 return NS_ERROR_NOT_AVAILABLE;
50 /**
51 * Invalidate if a blob recording or simple surface provider (both are only
52 * used by vector images), requiring it to be regenerated.
54 virtual void InvalidateSurface() {}
56 protected:
57 WebRenderImageProvider(const ImageResource* aImage);
59 private:
60 ImageProviderId mProviderId;
63 } // namespace image
64 } // namespace mozilla
66 #endif /* MOZILLA_IMAGE_WEBRENDERIMAGEPROVIDER_H_ */