Files
palemoon27/gfx/layers/client/ClientImageLayer.cpp
T
roytam1 3fcb35e62d import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1163719 - Store startup cache entries in loading order; r=nfroyd (410ef75ff)
- Bug 1072313: P1. Make MacIOSurface refcount thread-safe. r=mattwoodrow (3be93ce91)
- Bug 1072313: P2 Prevent instanciating MacIOSurfaceLib directly. r=mattwoodrow (8d5d7e2e5)
- Bug 1178513 - Export libxul symbols needed by ACL. r=mattwoodrow (b01035079)
- Bug 1143575. Remove unused CompositableClient::OnTransaction. r=nical (8901f1fe8)
- Bug 1143575. Convert SetCurrentImage(nullptr) callers to call ClearAllImages instead. r=nical (1a89f04f0)
- Bug 1143575. Fix indent. r=cpearce (6b8f4e725)
- Bug 1179111 part 1 - Implement CSSAnimation.animationName; r=smaug, r=jwatt (0d27b5d2e)
- Bug 1179111 part 2 - Implement CSSTransition.transitionProperty; r=smaug, r=jwatt (f395dfc55)
- Bug 1144615 - 2 - Adds a playbackRate selector widget to the animation panel; r=vporof (d538eb734)
- Bug 1144615 - 1 - Minor css fixes in animation panel; r=bgrins (661a6feab)
- Bug 1144615 - 3 - Tests for the playbackRate selection UI in the animation panel; r=vporof (82a4b4f91)
- Bug 1120833 - 3 - Refresh the list of animation widgets when new animations are added; r=miker (f833abeb2)
- Bug 1153903 - Get rid of logspam during devtools talos test runs;r=pbrosset (77f1968d2)
- Bug 1155653 - Preview animation target nodes in animationinspector panel; r=bgrins (61f197d75)
- Bug 1151018 - Refresh the list of Animation widgets when the animation panel loads; r=bgrins (9351a0b64)
- Bug 1155663 - Show animations as synchronized time blocks in animation inspector; r=bgrins (66f544aea)
- Bug 1149999 - 2 - Send animation removed events to the animation-panel for re-starting transitions; r=past (2913b4d4b)
- Bug 1179111 part 3 - Make DevTools read the appropriate name property; r=pbrosset (6dfecd643)
- Bug 1179111 part 4 - Remove KeyframeEffectReadOnly.name; r=smaug (85894f42f)
- Bug 1004383 follow-up: Mark ElementPropertyTransition::AsTransition() as override (f37e36e8a)
- Bug 1179111 part 5 - Remove Name() methods; r=jwatt (8909c4781)
- Bug 1143575. Remove Theora-only duplicate frame optimization. r=cpearce (fe53385ec)
- Bug 1172825 - MDSM playback should depend on IsPlaying() instead of |mPlayState|. r=cpearce. (9a9cf656d)
- Bug 1163223 - Switch test_buffered to use timeupdate rather than loadedmetadata. r=cpearce (b91463faf)
- Bug 1163223 - Move bailout case in GetBuffered into the readers. r=jww (c875c1d71)
- Bug 1161901 - Dispatch MediaDecoderReader::SetIdle directly. r=jww (a9ad2582d)
- Bug 1161901 - Use ProxyMediaCall instead of MDSM::ShutdownReader. r=jww (c866b524c)
- Bug 1161901 - Hoist MDSM shutdown logic into MDSM::Shutdown and remove brittle requirement that RunStateMachine only happen once in SHUTDOWN state. r=jww (0d81368d6)
- Bug 1153149 - Remove IsWaitingMediaResources() from PlatformDecoderModule. r=jya (70bd67ee3)
- Bug 1161984 - Get rid of IsWaitingMediaResources() in MP4Reader. r=jya (94dd1f58c)
- Bug 1163223 - Introduce StartTimeRendezvous and route samples through it. r=jww (b2a80c47a)
- Bug 1163223 - Use AwaitStartTime to handle metadata end time. r=jww (8e22fc3fd)
- Bug 1163223 - Use AwaitStartTime to invoke MediaDecoderReader::SetStartTime. r=jww (6141f5303)
- Bug 1172387 - Clean up code of MediaDecoderStateMachine::StopAudioThread. r=kinetik. (717640128)
- Bug 1163223 - Adjust incoming samples for start time. r=jww (c4029f934)
2021-03-25 09:18:42 +08:00

176 lines
5.0 KiB
C++

/* -*- 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/. */
#include "ClientLayerManager.h" // for ClientLayerManager, etc
#include "ImageContainer.h" // for AutoLockImage, etc
#include "ImageLayers.h" // for ImageLayer
#include "mozilla/Attributes.h" // for override
#include "mozilla/RefPtr.h" // for RefPtr
#include "mozilla/layers/CompositorTypes.h"
#include "mozilla/layers/ImageClient.h" // for ImageClient, etc
#include "mozilla/layers/LayersMessages.h" // for ImageLayerAttributes, etc
#include "mozilla/mozalloc.h" // for operator delete, etc
#include "nsAutoPtr.h" // for nsRefPtr, getter_AddRefs, etc
#include "nsCOMPtr.h" // for already_AddRefed
#include "nsDebug.h" // for NS_ASSERTION
#include "nsISupportsImpl.h" // for Layer::AddRef, etc
#include "nsRegion.h" // for nsIntRegion
namespace mozilla {
namespace layers {
using namespace mozilla::gfx;
class ClientImageLayer : public ImageLayer,
public ClientLayer {
public:
explicit ClientImageLayer(ClientLayerManager* aLayerManager)
: ImageLayer(aLayerManager, static_cast<ClientLayer*>(this))
, mImageClientTypeContainer(CompositableType::UNKNOWN)
{
MOZ_COUNT_CTOR(ClientImageLayer);
}
protected:
virtual ~ClientImageLayer()
{
DestroyBackBuffer();
MOZ_COUNT_DTOR(ClientImageLayer);
}
virtual void SetContainer(ImageContainer* aContainer) override
{
ImageLayer::SetContainer(aContainer);
mImageClientTypeContainer = CompositableType::UNKNOWN;
}
virtual void SetVisibleRegion(const nsIntRegion& aRegion) override
{
NS_ASSERTION(ClientManager()->InConstruction(),
"Can only set properties in construction phase");
ImageLayer::SetVisibleRegion(aRegion);
}
virtual void RenderLayer() override;
virtual void ClearCachedResources() override
{
DestroyBackBuffer();
}
virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs) override
{
aAttrs = ImageLayerAttributes(mFilter, mScaleToSize, mScaleMode);
}
virtual Layer* AsLayer() override { return this; }
virtual ShadowableLayer* AsShadowableLayer() override { return this; }
virtual void Disconnect() override
{
DestroyBackBuffer();
ClientLayer::Disconnect();
}
void DestroyBackBuffer()
{
if (mImageClient) {
mImageClient->SetLayer(nullptr);
mImageClient->OnDetach();
mImageClient = nullptr;
}
}
virtual CompositableClient* GetCompositableClient() override
{
return mImageClient;
}
protected:
ClientLayerManager* ClientManager()
{
return static_cast<ClientLayerManager*>(mManager);
}
CompositableType GetImageClientType()
{
if (mImageClientTypeContainer != CompositableType::UNKNOWN) {
return mImageClientTypeContainer;
}
if (mContainer->IsAsync()) {
mImageClientTypeContainer = CompositableType::IMAGE_BRIDGE;
return mImageClientTypeContainer;
}
AutoLockImage autoLock(mContainer);
#ifdef MOZ_WIDGET_GONK
if (autoLock.HasImage() &&
autoLock.GetImage()->GetFormat() == ImageFormat::OVERLAY_IMAGE) {
mImageClientTypeContainer = CompositableType::IMAGE_OVERLAY;
return mImageClientTypeContainer;
}
#endif
mImageClientTypeContainer = autoLock.HasImage()
? CompositableType::IMAGE : CompositableType::UNKNOWN;
return mImageClientTypeContainer;
}
RefPtr<ImageClient> mImageClient;
CompositableType mImageClientTypeContainer;
};
void
ClientImageLayer::RenderLayer()
{
RenderMaskLayers(this);
if (!mContainer) {
return;
}
if (!mImageClient ||
!mImageClient->UpdateImage(mContainer, GetContentFlags())) {
CompositableType type = GetImageClientType();
if (type == CompositableType::UNKNOWN) {
return;
}
TextureFlags flags = TextureFlags::DEFAULT;
if (mDisallowBigImage) {
flags |= TextureFlags::DISALLOW_BIGIMAGE;
}
mImageClient = ImageClient::CreateImageClient(type,
ClientManager()->AsShadowForwarder(),
flags);
if (!mImageClient) {
return;
}
mImageClient->SetLayer(this);
if (HasShadow() && !mContainer->IsAsync()) {
mImageClient->Connect();
ClientManager()->AsShadowForwarder()->Attach(mImageClient, this);
}
if (!mImageClient->UpdateImage(mContainer, GetContentFlags())) {
return;
}
}
ClientManager()->Hold(this);
}
already_AddRefed<ImageLayer>
ClientLayerManager::CreateImageLayer()
{
NS_ASSERTION(InConstruction(), "Only allowed in construction phase");
nsRefPtr<ClientImageLayer> layer =
new ClientImageLayer(this);
CREATE_SHADOW(Image);
return layer.forget();
}
} // namespace layers
} // namespace mozilla