Files
palemoon27/gfx/layers/client/ImageClient.h
T
roytam1 c34e72358b import changes from `dev' branch of rmottola/Arctic-Fox:
- nsTArray*: fully sync with AF, and use ActualAlloc::Successful (adaf2f742)
- Bug 1182808 - Part 2: Remove AlignedFallibleTArray. r=padenot (e0f112fb4)
- Bug 1182808 - Part 3: Rename AlignedTArray_Impl to AlignedTArray and remove existing AlignedTArray. r=padenot (ff2beea1e)
- Bug 1148582 - Include the rounded clip of the async scrolled scroll frame in its mAncestorClip. (1633f8cb2)
- Bug 1148582 - Support multiple mask layers per layer in LayerManagerComposite. (d292070f8)
- Bug 1143575. #include nsDebug.h in YCbCrImageDataSerializer.cpp for NS_WARN_IF. r=nical (c9a7fe42c)
- Bug 1143575. Remove ImageClientBridge::Updated. r=nical (095f1f806)
- Bug 1143575. Pass a picture rect with OpUseOverlaySource and OpUseTexture, and eliminate OpUpdatePictureRect. r=nical (c134913c2)
- Bug 1143575. Extend IPDL OpUseTexture to support multiple timestamped images. r=nical (54d018cd1)
- Bug 1143575. Replace ImageClientSingle::UpdateImage's use of Image serial numbers with ImageContainer state generation counters, and switch it to use ImageContainer::GetCurrentImages. r=nical (e2e096ad2)
- Bug 1143575. ImageClient::UpdateImage should not return false when there's no image, because recreating the ImageClient won't help. r=nical (4be2ed5ed)
- Bug 1143575. Make ImageClientSingle handle multiple textures. r=nical (8889f2639)
- Bug 1143575. Store composition time in Compositor. r=nical (1501cc5d0)
- Bug 1143575. Implement ImageHost support for multiple timed images. r=nical (99a440556)
- Bug 1168456 - Remove NotifyWaitingForResourcesStatusChanged() call from MediaCodecReader r=bholley,bwu (efabdbeed)
- Bug 1163871: Use DebugOnly to suppress opt build warning in gonk nsAppShell.cpp. r=mwu (fc77b0322)
- Bug 1165161 - stop bootAnim with "browser-ui-startup-complete" event.  r=mwu (a2a9bbfdd)
- Bug 949036 - Make ID3v2 tag detection more careful - not every bit of data containing ID3 is a tag. r=eflores (ac590bbd1)
- bug 1137076 handle null mDecoder during Reader shutdown r=edwin (1507b0627)
- Bug 1150322 - Fix duration parsing in MediaOmxReader - r=sotaro (93577cfea)
- Bug 1112219 - Implement platform independent MediaResourceManager r=cpearce,bwu,nical (cc722ccf3)
- Bug 1091037 - Raise ImageBridge thread priority r=gsvelto,nical (d66ecdd06)
- Bug 1143575. Route ImageCompositeNotifications to ImageContainers. r=nical (fe5d3da61)
- bug 1184801 process AnalyserNode input only when required r=padenot (8079b66f5)
- Bug 1157768 - FFTBlock Changes for using libav fft; r=padenot (3238d710c)
- bug 914392 move mSharedBuffers ownership to engine r=padenot (4444d8352)
2021-03-23 10:01:13 +08:00

177 lines
5.7 KiB
C++

/* -*- Mode: C++; tab-width: 20; 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_GFX_IMAGECLIENT_H
#define MOZILLA_GFX_IMAGECLIENT_H
#include <stdint.h> // for uint32_t, uint64_t
#include <sys/types.h> // for int32_t
#include "mozilla/Attributes.h" // for override
#include "mozilla/RefPtr.h" // for RefPtr, already_AddRefed
#include "mozilla/gfx/Types.h" // for SurfaceFormat
#include "mozilla/layers/AsyncTransactionTracker.h" // for AsyncTransactionTracker
#include "mozilla/layers/CompositableClient.h" // for CompositableClient
#include "mozilla/layers/CompositorTypes.h" // for CompositableType, etc
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
#include "mozilla/layers/TextureClient.h" // for TextureClient, etc
#include "mozilla/mozalloc.h" // for operator delete
#include "nsCOMPtr.h" // for already_AddRefed
#include "nsRect.h" // for mozilla::gfx::IntRect
namespace mozilla {
namespace layers {
class ClientLayer;
class CompositableForwarder;
class AsyncTransactionTracker;
class Image;
class ImageContainer;
class ShadowableLayer;
/**
* Image clients are used by basic image layers on the content thread, they
* always match with an ImageHost on the compositor thread. See
* CompositableClient.h for information on connecting clients to hosts.
*/
class ImageClient : public CompositableClient
{
public:
/**
* Creates, configures, and returns a new image client. If necessary, a
* message will be sent to the compositor to create a corresponding image
* host.
*/
static already_AddRefed<ImageClient> CreateImageClient(CompositableType aImageHostType,
CompositableForwarder* aFwd,
TextureFlags aFlags);
virtual ~ImageClient() {}
/**
* Update this ImageClient from aContainer in aLayer
* returns false if this is the wrong kind of ImageClient for aContainer.
* Note that returning true does not necessarily imply success
*/
virtual bool UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags) = 0;
virtual already_AddRefed<Image> CreateImage(ImageFormat aFormat) = 0;
void SetLayer(ClientLayer* aLayer) { mLayer = aLayer; }
ClientLayer* GetLayer() const { return mLayer; }
/**
* asynchronously remove all the textures used by the image client.
*
*/
virtual void FlushAllImages(bool aExceptFront,
AsyncTransactionWaiter* aAsyncTransactionWaiter) {}
virtual void RemoveTexture(TextureClient* aTexture) override;
void RemoveTextureWithWaiter(TextureClient* aTexture,
AsyncTransactionWaiter* aAsyncTransactionWaiter = nullptr);
protected:
ImageClient(CompositableForwarder* aFwd, TextureFlags aFlags,
CompositableType aType);
ClientLayer* mLayer;
CompositableType mType;
uint32_t mLastUpdateGenerationCounter;
};
/**
* An image client which uses a single texture client.
*/
class ImageClientSingle : public ImageClient
{
public:
ImageClientSingle(CompositableForwarder* aFwd,
TextureFlags aFlags,
CompositableType aType);
virtual bool UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags) override;
virtual void OnDetach() override;
virtual bool AddTextureClient(TextureClient* aTexture) override;
virtual TextureInfo GetTextureInfo() const override;
virtual already_AddRefed<Image> CreateImage(ImageFormat aFormat) override;
virtual void FlushAllImages(bool aExceptFront,
AsyncTransactionWaiter* aAsyncTransactionWaiter) override;
protected:
struct Buffer {
RefPtr<TextureClient> mTextureClient;
int32_t mImageSerial;
};
nsTArray<Buffer> mBuffers;
};
/**
* Image class to be used for async image uploads using the image bridge
* protocol.
* We store the ImageBridge id in the TextureClientIdentifier.
*/
class ImageClientBridge : public ImageClient
{
public:
ImageClientBridge(CompositableForwarder* aFwd,
TextureFlags aFlags);
virtual bool UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags) override;
virtual bool Connect(ImageContainer* aImageContainer) override { return false; }
virtual TextureInfo GetTextureInfo() const override
{
return TextureInfo(mType);
}
virtual void SetIPDLActor(CompositableChild* aChild) override
{
MOZ_ASSERT(!aChild, "ImageClientBridge should not have IPDL actor");
}
virtual already_AddRefed<Image> CreateImage(ImageFormat aFormat) override
{
NS_WARNING("Should not create an image through an ImageClientBridge");
return nullptr;
}
protected:
uint64_t mAsyncContainerID;
};
#ifdef MOZ_WIDGET_GONK
/**
* And ImageClient to handle opaque video stream.
* Such video stream does not upload new Image for each frame.
* Gecko have no way to get the buffer content from the Image, since the Image
* does not contain the real buffer.
* It need special hardware to display the Image
*/
class ImageClientOverlay : public ImageClient
{
public:
ImageClientOverlay(CompositableForwarder* aFwd,
TextureFlags aFlags);
virtual bool UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags);
virtual already_AddRefed<Image> CreateImage(ImageFormat aFormat);
TextureInfo GetTextureInfo() const override
{
return TextureInfo(CompositableType::IMAGE_OVERLAY);
}
};
#endif
} // namespace layers
} // namespace mozilla
#endif