mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
e4e2da55c9
The bulk of this commit was generated with a script, executed at the top level of a typical source code checkout. The only non-machine-generated part was modifying MFBT's moz.build to reflect the new naming. CLOSED TREE makes big refactorings like this a piece of cake. # The main substitution. find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \ xargs perl -p -i -e ' s/nsRefPtr\.h/RefPtr\.h/g; # handle includes s/nsRefPtr ?</RefPtr</g; # handle declarations and variables ' # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h. perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h # Handle nsRefPtr.h itself, a couple places that define constructors # from nsRefPtr, and code generators specially. We do this here, rather # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename # things like nsRefPtrHashtable. perl -p -i -e 's/nsRefPtr/RefPtr/g' \ mfbt/nsRefPtr.h \ xpcom/glue/nsCOMPtr.h \ xpcom/base/OwningNonNull.h \ ipc/ipdl/ipdl/lower.py \ ipc/ipdl/ipdl/builtin.py \ dom/bindings/Codegen.py \ python/lldbutils/lldbutils/utils.py # In our indiscriminate substitution above, we renamed # nsRefPtrGetterAddRefs, the class behind getter_AddRefs. Fix that up. find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \ xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g' if [ -d .git ]; then git mv mfbt/nsRefPtr.h mfbt/RefPtr.h else hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h fi
152 lines
4.0 KiB
C++
152 lines
4.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/. */
|
|
|
|
#ifndef MOZILLA_VIDEOSEGMENT_H_
|
|
#define MOZILLA_VIDEOSEGMENT_H_
|
|
|
|
#include "MediaSegment.h"
|
|
#include "nsCOMPtr.h"
|
|
#include "gfxPoint.h"
|
|
#include "nsAutoPtr.h"
|
|
#if defined(MOZILLA_XPCOMRT_API)
|
|
#include "SimpleImageBuffer.h"
|
|
#else
|
|
#include "ImageContainer.h"
|
|
#endif
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
class Image;
|
|
} // namespace layers
|
|
|
|
class VideoFrame {
|
|
public:
|
|
#if defined(MOZILLA_XPCOMRT_API)
|
|
typedef mozilla::SimpleImageBuffer Image;
|
|
#else
|
|
typedef mozilla::layers::Image Image;
|
|
#endif
|
|
|
|
VideoFrame(already_AddRefed<Image>& aImage, const gfx::IntSize& aIntrinsicSize);
|
|
VideoFrame();
|
|
~VideoFrame();
|
|
|
|
bool operator==(const VideoFrame& aFrame) const
|
|
{
|
|
return mIntrinsicSize == aFrame.mIntrinsicSize &&
|
|
mForceBlack == aFrame.mForceBlack &&
|
|
((mForceBlack && aFrame.mForceBlack) || mImage == aFrame.mImage);
|
|
}
|
|
bool operator!=(const VideoFrame& aFrame) const
|
|
{
|
|
return !operator==(aFrame);
|
|
}
|
|
|
|
Image* GetImage() const { return mImage; }
|
|
void SetForceBlack(bool aForceBlack) { mForceBlack = aForceBlack; }
|
|
bool GetForceBlack() const { return mForceBlack; }
|
|
const gfx::IntSize& GetIntrinsicSize() const { return mIntrinsicSize; }
|
|
void SetNull();
|
|
void TakeFrom(VideoFrame* aFrame);
|
|
|
|
#if !defined(MOZILLA_XPCOMRT_API)
|
|
// Create a planar YCbCr black image.
|
|
static already_AddRefed<Image> CreateBlackImage(const gfx::IntSize& aSize);
|
|
#endif // !defined(MOZILLA_XPCOMRT_API)
|
|
|
|
protected:
|
|
// mImage can be null to indicate "no video" (aka "empty frame"). It can
|
|
// still have an intrinsic size in this case.
|
|
RefPtr<Image> mImage;
|
|
// The desired size to render the video frame at.
|
|
gfx::IntSize mIntrinsicSize;
|
|
bool mForceBlack;
|
|
};
|
|
|
|
struct VideoChunk {
|
|
VideoChunk();
|
|
~VideoChunk();
|
|
void SliceTo(StreamTime aStart, StreamTime aEnd)
|
|
{
|
|
NS_ASSERTION(aStart >= 0 && aStart < aEnd && aEnd <= mDuration,
|
|
"Slice out of bounds");
|
|
mDuration = aEnd - aStart;
|
|
}
|
|
StreamTime GetDuration() const { return mDuration; }
|
|
bool CanCombineWithFollowing(const VideoChunk& aOther) const
|
|
{
|
|
return aOther.mFrame == mFrame;
|
|
}
|
|
bool IsNull() const { return !mFrame.GetImage(); }
|
|
void SetNull(StreamTime aDuration)
|
|
{
|
|
mDuration = aDuration;
|
|
mFrame.SetNull();
|
|
mTimeStamp = TimeStamp();
|
|
}
|
|
void SetForceBlack(bool aForceBlack) { mFrame.SetForceBlack(aForceBlack); }
|
|
|
|
size_t SizeOfExcludingThisIfUnshared(MallocSizeOf aMallocSizeOf) const
|
|
{
|
|
// Future:
|
|
// - mFrame
|
|
return 0;
|
|
}
|
|
|
|
StreamTime mDuration;
|
|
VideoFrame mFrame;
|
|
mozilla::TimeStamp mTimeStamp;
|
|
};
|
|
|
|
class VideoSegment : public MediaSegmentBase<VideoSegment, VideoChunk> {
|
|
public:
|
|
#if defined(MOZILLA_XPCOMRT_API)
|
|
typedef mozilla::SimpleImageBuffer Image;
|
|
#else
|
|
typedef mozilla::layers::Image Image;
|
|
#endif
|
|
typedef mozilla::gfx::IntSize IntSize;
|
|
|
|
VideoSegment();
|
|
~VideoSegment();
|
|
|
|
void AppendFrame(already_AddRefed<Image>&& aImage,
|
|
StreamTime aDuration,
|
|
const IntSize& aIntrinsicSize,
|
|
bool aForceBlack = false);
|
|
const VideoFrame* GetLastFrame(StreamTime* aStart = nullptr)
|
|
{
|
|
VideoChunk* c = GetLastChunk();
|
|
if (!c) {
|
|
return nullptr;
|
|
}
|
|
if (aStart) {
|
|
*aStart = mDuration - c->mDuration;
|
|
}
|
|
return &c->mFrame;
|
|
}
|
|
// Override default impl
|
|
virtual void ReplaceWithDisabled() override {
|
|
for (ChunkIterator i(*this);
|
|
!i.IsEnded(); i.Next()) {
|
|
VideoChunk& chunk = *i;
|
|
chunk.SetForceBlack(true);
|
|
}
|
|
}
|
|
|
|
// Segment-generic methods not in MediaSegmentBase
|
|
static Type StaticType() { return VIDEO; }
|
|
|
|
virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override
|
|
{
|
|
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
|
|
}
|
|
};
|
|
|
|
} // namespace mozilla
|
|
|
|
#endif /* MOZILLA_VIDEOSEGMENT_H_ */
|