Files
palemoon27/gfx/layers/basic/BasicImageLayer.cpp
T
roytam1 69d3703748 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1143575. Reimplement ImageContainer::GetPaintCount to be composition-aware. r=nical (fdae9bbe2)
- Bug 1143575. Let callers of ImageContainer::SetCurrentImages specify frame IDs. r=nical (c3d1be5c7)
- Bug 1143575. Let ImageContainer::SetCurrentImages accept multiple images. r=nical (eca5b7bf4)
- Bug 1179116. Part 1 - clean up code of MediaDecoderStateMachine::MaybeStartPlayback(). r=cpearce. (5a8514857)
- Bug 1179116. Part 2 - clean up code of MediaDecoderStateMachine::FinishDecodeFirstFrame(). r=cpearce. (e42aba701)
- Bug 1179116. Part 3 - remove unused code. r=cpearce. (f49fe1fb2)
- Bug 1143575. Introduce VideoFrameContainer::ClearCurrentFrame(size), and don't increment mFrameID when clearing frames. r=cpearce (5357bf3bc)
- Bug 1143575. Introduce VideoFrameContainer::SetCurrentFrames. r=cpearce (fa56c22fe)
- Bug 1143575. Add MediaQueue::GetFirstElements. r=cpearce (a1d2378b1)
- Bug 1143575. Refactor UpdateRenderedVideoFrames to support pushing multiple frames from the VideoQueue to the ImageContainer. r=cpearce (37de445b6)
- space (2c87961f2)
- Bug 1181504. Part 1 - add assertions to MediaDecoderStateMachine::GetAudioClock(). r=kinetik. (9efc04e7e)
- Bug 1112438 - Make newCurrentFrameTime more accurate while seeking by checking audio & video timestamp boundary in addition. r=cpearce (2bfc18fa7)
- Bug 1146304 - Touch slider bar or tap forward button, the video got stuck 1s then resume playing. r=cpearce (27d966133)
- Bug 1181504. Part 2 - remove MediaDecoderStateMachine::mAudioStartTime. r=kinetik. (564a77d09)
- Bug 1182738. Part 1 - have DecodedStream::GetPosition() return a position including the start time. (613a0c871)
- Bug 1182738. Part 2 - remove MediaDecoderStateMachine::mStreamStartTime. (5c44e9a97)
- Bug 1182737. Part 1 - have DecodedStream keep reference to media queues of MDSM so we don't have to pass them everytime. (53ac5a2ec)
- Bug 1182737. Part 2 - remove unnecessary code. (bd0814e9d)
- Bug 1182737. Part 3 - make start/stop playback of DecodedStream more consistent with that of AudioSink. (b84f1cc01)
- Bug 1183007. Part 2 - remove dependency on MDSM::OnAudioEndTimeUpdate from AudioSink. r=kinetik. (848cf50fb)
- Bug 1183007. Part 2.5 - don't call AudioEndTime() after mAudioSink becomes null. r=kinetik. (2b6ef5079)
- Bug 1184412. Part 1 - remove dependency on MDSM::OnAudioEndTimeUpdate from DecodedStream. r=roc. (680a4346f)
- Bug 1184412. Part 2 - remove code that is not used anymore. r=roc. (8aaa00df2)
- Bug 1184010 - Put Mirrors/Canonicals together. r=jya. (ce4e2de38)
- adapted - Bug 1161901 - Make MDSM::ScheduleStateMachine runs on the state machine task queue only. r=jww (41acdb0e3)
2021-07-23 09:41:15 +08:00

121 lines
3.7 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 "BasicLayersImpl.h" // for FillRectWithMask, etc
#include "ImageContainer.h" // for AutoLockImage, etc
#include "ImageLayers.h" // for ImageLayer
#include "Layers.h" // for Layer (ptr only), etc
#include "basic/BasicImplData.h" // for BasicImplData
#include "basic/BasicLayers.h" // for BasicLayerManager
#include "mozilla/mozalloc.h" // for operator new
#include "nsAutoPtr.h" // for nsRefPtr, getter_AddRefs, etc
#include "nsCOMPtr.h" // for already_AddRefed
#include "nsDebug.h" // for NS_ASSERTION
#include "nsISupportsImpl.h" // for gfxPattern::Release, etc
#include "nsRect.h" // for mozilla::gfx::IntRect
#include "nsRegion.h" // for nsIntRegion
#include "mozilla/gfx/Point.h" // for IntSize
using namespace mozilla::gfx;
namespace mozilla {
namespace layers {
class BasicImageLayer : public ImageLayer, public BasicImplData {
public:
explicit BasicImageLayer(BasicLayerManager* aLayerManager) :
ImageLayer(aLayerManager, static_cast<BasicImplData*>(this)),
mSize(-1, -1)
{
MOZ_COUNT_CTOR(BasicImageLayer);
}
protected:
virtual ~BasicImageLayer()
{
MOZ_COUNT_DTOR(BasicImageLayer);
}
public:
virtual void SetVisibleRegion(const nsIntRegion& aRegion) override
{
NS_ASSERTION(BasicManager()->InConstruction(),
"Can only set properties in construction phase");
ImageLayer::SetVisibleRegion(aRegion);
}
virtual void Paint(DrawTarget* aDT,
const gfx::Point& aDeviceOffset,
Layer* aMaskLayer) override;
virtual already_AddRefed<SourceSurface> GetAsSourceSurface() override;
protected:
BasicLayerManager* BasicManager()
{
return static_cast<BasicLayerManager*>(mManager);
}
gfx::IntSize mSize;
};
void
BasicImageLayer::Paint(DrawTarget* aDT,
const gfx::Point& aDeviceOffset,
Layer* aMaskLayer)
{
if (IsHidden() || !mContainer) {
return;
}
nsRefPtr<ImageFactory> originalIF = mContainer->GetImageFactory();
mContainer->SetImageFactory(mManager->IsCompositingCheap() ? nullptr : BasicManager()->GetImageFactory());
AutoLockImage autoLock(mContainer);
Image *image = autoLock.GetImage();
if (!image) {
mContainer->SetImageFactory(originalIF);
return;
}
RefPtr<gfx::SourceSurface> surface = image->GetAsSourceSurface();
if (!surface || !surface->IsValid()) {
mContainer->SetImageFactory(originalIF);
return;
}
gfx::IntSize size = mSize = surface->GetSize();
FillRectWithMask(aDT, aDeviceOffset, Rect(0, 0, size.width, size.height),
surface, ToFilter(mFilter),
DrawOptions(GetEffectiveOpacity(), GetEffectiveOperator(this)),
aMaskLayer);
mContainer->SetImageFactory(originalIF);
}
already_AddRefed<SourceSurface>
BasicImageLayer::GetAsSourceSurface()
{
if (!mContainer) {
return nullptr;
}
AutoLockImage lockImage(mContainer);
Image* image = lockImage.GetImage();
if (!image) {
return nullptr;
}
return image->GetAsSourceSurface();
}
already_AddRefed<ImageLayer>
BasicLayerManager::CreateImageLayer()
{
NS_ASSERTION(InConstruction(), "Only allowed in construction phase");
nsRefPtr<ImageLayer> layer = new BasicImageLayer(this);
return layer.forget();
}
} // namespace layers
} // namespace mozilla