Bug 784004 - Don't include Layers.h everywhere Part 3 r=nical

This commit is contained in:
David Zbarsky 2012-08-21 00:06:46 -04:00
parent 8b80664250
commit 3154e1b535
37 changed files with 317 additions and 155 deletions

View File

@ -42,6 +42,8 @@
#include "mozilla/Services.h"
#include "mozilla/dom/WebGLRenderingContextBinding.h"
#include "Layers.h"
using namespace mozilla;
using namespace mozilla::gl;
using namespace mozilla::layers;

View File

@ -66,6 +66,8 @@
#include "nsCSSParser.h"
#include "nsIMediaList.h"
#include "ImageContainer.h"
#ifdef MOZ_OGG
#include "nsOggDecoder.h"
#endif

View File

@ -20,6 +20,7 @@
#include "nsXPCOMStrings.h"
#include "prlock.h"
#include "nsThreadUtils.h"
#include "ImageContainer.h"
#include "nsIScriptSecurityManager.h"
#include "nsIXPConnect.h"

View File

@ -49,6 +49,7 @@ CPPSRCS = \
nsMediaDecoder.cpp \
StreamBuffer.cpp \
VideoFrameContainer.cpp \
VideoSegment.cpp \
VideoUtils.cpp \
$(NULL)

View File

@ -19,6 +19,7 @@
#include "VideoUtils.h"
#include "mozilla/Attributes.h"
#include "TrackUnionStream.h"
#include "ImageContainer.h"
using namespace mozilla::layers;

View File

@ -15,6 +15,7 @@
#include "TimeVarying.h"
#include "VideoFrameContainer.h"
#include "VideoSegment.h"
#include "nsThreadUtils.h"
class nsDOMMediaStream;

View File

@ -10,11 +10,26 @@
#include "nsIFrame.h"
#include "nsDisplayList.h"
#include "nsSVGEffects.h"
#include "ImageContainer.h"
using namespace mozilla::layers;
namespace mozilla {
VideoFrameContainer::VideoFrameContainer(nsHTMLMediaElement* aElement,
already_AddRefed<ImageContainer> aContainer)
: mElement(aElement),
mImageContainer(aContainer), mMutex("nsVideoFrameContainer"),
mIntrinsicSizeChanged(false), mImageSizeChanged(false),
mNeedInvalidation(true)
{
NS_ASSERTION(aElement, "aElement must not be null");
NS_ASSERTION(mImageContainer, "aContainer must not be null");
}
VideoFrameContainer::~VideoFrameContainer()
{}
void VideoFrameContainer::SetCurrentFrame(const gfxIntSize& aIntrinsicSize,
Image* aImage,
TimeStamp aTargetTime)
@ -40,6 +55,11 @@ void VideoFrameContainer::SetCurrentFrame(const gfxIntSize& aIntrinsicSize,
mPaintTarget = aTargetTime;
}
ImageContainer* VideoFrameContainer::GetImageContainer() {
return mImageContainer;
}
double VideoFrameContainer::GetFrameDelay()
{
MutexAutoLock lock(mMutex);

View File

@ -7,16 +7,22 @@
#ifndef VIDEOFRAMECONTAINER_H_
#define VIDEOFRAMECONTAINER_H_
#include "ImageContainer.h"
#include "mozilla/Mutex.h"
#include "mozilla/TimeStamp.h"
#include "nsISupportsImpl.h"
#include "gfxPoint.h"
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
class nsHTMLMediaElement;
namespace mozilla {
namespace layers {
class Image;
class ImageContainer;
}
/**
* This object is used in the decoder backend threads and the main thread
* to manage the "current video frame" state. This state includes timing data
@ -34,15 +40,8 @@ public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoFrameContainer)
VideoFrameContainer(nsHTMLMediaElement* aElement,
already_AddRefed<ImageContainer> aContainer)
: mElement(aElement),
mImageContainer(aContainer), mMutex("nsVideoFrameContainer"),
mIntrinsicSizeChanged(false), mImageSizeChanged(false),
mNeedInvalidation(true)
{
NS_ASSERTION(aElement, "aElement must not be null");
NS_ASSERTION(mImageContainer, "aContainer must not be null");
}
already_AddRefed<ImageContainer> aContainer);
~VideoFrameContainer();
// Call on any thread
void SetCurrentFrame(const gfxIntSize& aIntrinsicSize, Image* aImage,
@ -53,7 +52,7 @@ public:
double GetFrameDelay();
// Call on main thread
void Invalidate();
ImageContainer* GetImageContainer() { return mImageContainer; }
ImageContainer* GetImageContainer();
void ForgetElement() { mElement = nullptr; }
protected:

View File

@ -0,0 +1,59 @@
/* -*- 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 "VideoSegment.h"
#include "ImageContainer.h"
namespace mozilla {
using namespace layers;
VideoFrame::VideoFrame(already_AddRefed<Image> aImage, const gfxIntSize& aIntrinsicSize)
: mImage(aImage), mIntrinsicSize(aIntrinsicSize)
{}
VideoFrame::VideoFrame()
: mIntrinsicSize(0, 0)
{}
VideoFrame::~VideoFrame()
{}
void
VideoFrame::SetNull() {
mImage = nullptr;
mIntrinsicSize = gfxIntSize(0, 0);
}
void
VideoFrame::TakeFrom(VideoFrame* aFrame)
{
mImage = aFrame->mImage.forget();
mIntrinsicSize = aFrame->mIntrinsicSize;
}
VideoChunk::VideoChunk()
{}
VideoChunk::~VideoChunk()
{}
void
VideoSegment::AppendFrame(already_AddRefed<Image> aImage, TrackTicks aDuration,
const gfxIntSize& aIntrinsicSize)
{
VideoChunk* chunk = AppendChunk(aDuration);
VideoFrame frame(aImage, aIntrinsicSize);
chunk->mFrame.TakeFrom(&frame);
}
VideoSegment::VideoSegment()
: MediaSegmentBase<VideoSegment, VideoChunk>(VIDEO)
{}
VideoSegment::~VideoSegment()
{}
}

View File

@ -7,17 +7,24 @@
#define MOZILLA_VIDEOSEGMENT_H_
#include "MediaSegment.h"
#include "nsCOMPtr.h"
#include "gfxPoint.h"
#include "nsAutoPtr.h"
#include "ImageContainer.h"
namespace mozilla {
namespace layers {
class Image;
}
class VideoFrame {
public:
typedef mozilla::layers::Image Image;
VideoFrame(already_AddRefed<Image> aImage, const gfxIntSize& aIntrinsicSize)
: mImage(aImage), mIntrinsicSize(aIntrinsicSize) {}
VideoFrame() : mIntrinsicSize(0, 0) {}
VideoFrame(already_AddRefed<Image> aImage, const gfxIntSize& aIntrinsicSize);
VideoFrame();
~VideoFrame();
bool operator==(const VideoFrame& aFrame) const
{
@ -30,12 +37,8 @@ public:
Image* GetImage() const { return mImage; }
const gfxIntSize& GetIntrinsicSize() const { return mIntrinsicSize; }
void SetNull() { mImage = nullptr; mIntrinsicSize = gfxIntSize(0, 0); }
void TakeFrom(VideoFrame* aFrame)
{
mImage = aFrame->mImage.forget();
mIntrinsicSize = aFrame->mIntrinsicSize;
}
void SetNull();
void TakeFrom(VideoFrame* aFrame);
protected:
// mImage can be null to indicate "no video" (aka "empty frame"). It can
@ -47,6 +50,8 @@ protected:
struct VideoChunk {
VideoChunk();
~VideoChunk();
void SliceTo(TrackTicks aStart, TrackTicks aEnd)
{
NS_ASSERTION(aStart >= 0 && aStart < aEnd && aEnd <= mDuration,
@ -73,15 +78,11 @@ class VideoSegment : public MediaSegmentBase<VideoSegment, VideoChunk> {
public:
typedef mozilla::layers::Image Image;
VideoSegment() : MediaSegmentBase<VideoSegment, VideoChunk>(VIDEO) {}
VideoSegment();
~VideoSegment();
void AppendFrame(already_AddRefed<Image> aImage, TrackTicks aDuration,
const gfxIntSize& aIntrinsicSize)
{
VideoChunk* chunk = AppendChunk(aDuration);
VideoFrame frame(aImage, aIntrinsicSize);
chunk->mFrame.TakeFrom(&frame);
}
const gfxIntSize& aIntrinsicSize);
const VideoFrame* GetFrameAt(TrackTicks aOffset, TrackTicks* aStart = nullptr)
{
VideoChunk* c = FindChunkContaining(aOffset, aStart);

View File

@ -16,6 +16,7 @@
#include "nsBuiltinDecoderStateMachine.h"
#include "nsTimeRanges.h"
#include "nsContentUtils.h"
#include "ImageContainer.h"
using namespace mozilla;
@ -1047,3 +1048,46 @@ void nsBuiltinDecoder::NotifyAudioAvailableListener()
mDecoderStateMachine->NotifyAudioAvailableListener();
}
}
nsBuiltinDecoder::OutputMediaStream::OutputMediaStream()
{
}
nsBuiltinDecoder::OutputMediaStream::~OutputMediaStream()
{
}
void nsBuiltinDecoder::OutputMediaStream::Init(PRInt64 aInitialTime, SourceMediaStream* aStream, bool aFinishWhenEnded)
{
mLastAudioPacketTime = -1;
mLastAudioPacketEndTime = -1;
mAudioFramesWrittenBaseTime = aInitialTime;
mAudioFramesWritten = 0;
mNextVideoTime = aInitialTime;
mStream = aStream;
mStreamInitialized = false;
mFinishWhenEnded = aFinishWhenEnded;
mHaveSentFinish = false;
mHaveSentFinishAudio = false;
mHaveSentFinishVideo = false;
}
nsBuiltinDecoder::OutputMediaStream::OutputMediaStream(const OutputMediaStream& rhs)
{
mLastAudioPacketTime = rhs.mLastAudioPacketTime;
mLastAudioPacketEndTime = rhs.mLastAudioPacketEndTime;
mAudioFramesWritten = rhs.mAudioFramesWritten;
mAudioFramesWrittenBaseTime = rhs.mAudioFramesWrittenBaseTime;
mNextVideoTime = rhs.mNextVideoTime;
mLastVideoImage = rhs.mLastVideoImage;
mStream = rhs.mStream;
mLastVideoImageDisplaySize = rhs.mLastVideoImageDisplaySize;
mStreamInitialized = rhs.mStreamInitialized;
mFinishWhenEnded = rhs.mFinishWhenEnded;
mHaveSentFinish = rhs.mHaveSentFinish;
mHaveSentFinishAudio = rhs.mHaveSentFinishAudio;
mHaveSentFinishVideo = rhs.mHaveSentFinishVideo;
}

View File

@ -202,7 +202,7 @@ class Image;
} //namespace
} //namespace
typedef mozilla::layers::Image Image;
typedef mozilla::layers::Image Image;
class nsAudioStream;
@ -380,20 +380,12 @@ public:
virtual void AddOutputStream(SourceMediaStream* aStream, bool aFinishWhenEnded);
// Protected by mReentrantMonitor. All decoder output is copied to these streams.
struct OutputMediaStream {
void Init(PRInt64 aInitialTime, SourceMediaStream* aStream, bool aFinishWhenEnded)
{
mLastAudioPacketTime = -1;
mLastAudioPacketEndTime = -1;
mAudioFramesWrittenBaseTime = aInitialTime;
mAudioFramesWritten = 0;
mNextVideoTime = aInitialTime;
mStream = aStream;
mStreamInitialized = false;
mFinishWhenEnded = aFinishWhenEnded;
mHaveSentFinish = false;
mHaveSentFinishAudio = false;
mHaveSentFinishVideo = false;
}
OutputMediaStream();
~OutputMediaStream();
OutputMediaStream(const OutputMediaStream& rhs);
void Init(PRInt64 aInitialTime, SourceMediaStream* aStream, bool aFinishWhenEnded);
PRInt64 mLastAudioPacketTime; // microseconds
PRInt64 mLastAudioPacketEndTime; // microseconds
// Count of audio frames written to the stream

View File

@ -8,6 +8,7 @@
#include "nsBuiltinDecoderReader.h"
#include "nsBuiltinDecoderStateMachine.h"
#include "VideoUtils.h"
#include "ImageContainer.h"
#include "mozilla/mozalloc.h"
#include "mozilla/StandardInteger.h"
@ -86,6 +87,42 @@ nsVideoInfo::ValidateVideoRegion(const nsIntSize& aFrame,
aDisplay.width * aDisplay.height != 0;
}
VideoData:: VideoData(PRInt64 aOffset, PRInt64 aTime, PRInt64 aEndTime, PRInt64 aTimecode)
: mOffset(aOffset),
mTime(aTime),
mEndTime(aEndTime),
mTimecode(aTimecode),
mDuplicate(true),
mKeyframe(false)
{
MOZ_COUNT_CTOR(VideoData);
NS_ASSERTION(aEndTime >= aTime, "Frame must start before it ends.");
}
VideoData::VideoData(PRInt64 aOffset,
PRInt64 aTime,
PRInt64 aEndTime,
bool aKeyframe,
PRInt64 aTimecode,
nsIntSize aDisplay)
: mDisplay(aDisplay),
mOffset(aOffset),
mTime(aTime),
mEndTime(aEndTime),
mTimecode(aTimecode),
mDuplicate(false),
mKeyframe(aKeyframe)
{
MOZ_COUNT_CTOR(VideoData);
NS_ASSERTION(aEndTime >= aTime, "Frame must start before it ends.");
}
VideoData::~VideoData()
{
MOZ_COUNT_DTOR(VideoData);
}
VideoData* VideoData::Create(nsVideoInfo& aInfo,
ImageContainer* aContainer,
PRInt64 aOffset,
@ -181,6 +218,19 @@ VideoData* VideoData::Create(nsVideoInfo& aInfo,
return v.forget();
}
void* nsBuiltinDecoderReader::VideoQueueMemoryFunctor::operator()(void* anObject) {
const VideoData* v = static_cast<const VideoData*>(anObject);
if (!v->mImage) {
return nullptr;
}
NS_ASSERTION(v->mImage->GetFormat() == mozilla::ImageFormat::PLANAR_YCBCR,
"Wrong format?");
mozilla::layers::PlanarYCbCrImage* vi = static_cast<mozilla::layers::PlanarYCbCrImage*>(v->mImage.get());
mResult += vi->GetDataSize();
return nullptr;
}
nsBuiltinDecoderReader::nsBuiltinDecoderReader(nsBuiltinDecoder* aDecoder)
: mDecoder(aDecoder)
{

View File

@ -11,6 +11,7 @@
#include "mozilla/ReentrantMonitor.h"
#include "MediaStreamGraph.h"
#include "SharedBuffer.h"
#include "ImageLayers.h"
// Stores info relevant to presenting media frames.
class nsVideoInfo {
@ -174,10 +175,7 @@ public:
return new VideoData(aOffset, aTime, aEndTime, aTimecode);
}
~VideoData()
{
MOZ_COUNT_DTOR(VideoData);
}
~VideoData();
PRInt64 GetEnd() { return mEndTime; }
@ -208,35 +206,14 @@ public:
bool mKeyframe;
public:
VideoData(PRInt64 aOffset, PRInt64 aTime, PRInt64 aEndTime, PRInt64 aTimecode)
: mOffset(aOffset),
mTime(aTime),
mEndTime(aEndTime),
mTimecode(aTimecode),
mDuplicate(true),
mKeyframe(false)
{
MOZ_COUNT_CTOR(VideoData);
NS_ASSERTION(aEndTime >= aTime, "Frame must start before it ends.");
}
VideoData(PRInt64 aOffset, PRInt64 aTime, PRInt64 aEndTime, PRInt64 aTimecode);
VideoData(PRInt64 aOffset,
PRInt64 aTime,
PRInt64 aEndTime,
bool aKeyframe,
PRInt64 aTimecode,
nsIntSize aDisplay)
: mDisplay(aDisplay),
mOffset(aOffset),
mTime(aTime),
mEndTime(aEndTime),
mTimecode(aTimecode),
mDuplicate(false),
mKeyframe(aKeyframe)
{
MOZ_COUNT_CTOR(VideoData);
NS_ASSERTION(aEndTime >= aTime, "Frame must start before it ends.");
}
nsIntSize aDisplay);
};
@ -457,18 +434,7 @@ public:
public:
VideoQueueMemoryFunctor() : mResult(0) {}
virtual void* operator()(void* anObject) {
const VideoData* v = static_cast<const VideoData*>(anObject);
if (!v->mImage) {
return nullptr;
}
NS_ASSERTION(v->mImage->GetFormat() == mozilla::PLANAR_YCBCR,
"Wrong format?");
mozilla::layers::PlanarYCbCrImage* vi = static_cast<mozilla::layers::PlanarYCbCrImage*>(v->mImage.get());
mResult += vi->GetDataSize();
return nullptr;
}
virtual void* operator()(void* anObject);
PRInt64 mResult;
};

View File

@ -15,6 +15,7 @@
#include "nsDeque.h"
#include "AudioSegment.h"
#include "VideoSegment.h"
#include "ImageContainer.h"
#include "mozilla/Preferences.h"
#include "mozilla/StandardInteger.h"

View File

@ -8,6 +8,8 @@
#include "nsDOMFile.h"
#include "nsILocalFile.h"
#include "Layers.h"
#include "ImageContainer.h"
#include "ImageTypes.h"
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidBridge.h"

View File

@ -3,9 +3,31 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "MediaEngineWebRTC.h"
#include "ImageContainer.h"
namespace mozilla {
MediaEngineWebRTCVideoSource::MediaEngineWebRTCVideoSource(webrtc::VideoEngine* videoEnginePtr,
int index, int aFps)
: mVideoEngine(videoEnginePtr)
, mCapIndex(index)
, mWidth(640)
, mHeight(480)
, mState(kReleased)
, mMonitor("WebRTCCamera.Monitor")
, mFps(aFps)
, mInitDone(false)
, mInSnapshotMode(false)
, mSnapshotPath(NULL)
{
Init();
}
MediaEngineWebRTCVideoSource::~MediaEngineWebRTCVideoSource()
{
Shutdown();
}
void
MediaEngineWebRTC::EnumerateVideoDevices(nsTArray<nsRefPtr<MediaEngineVideoSource> >* aVSources)
{

View File

@ -66,19 +66,8 @@ public:
virtual int DeliverFrame(unsigned char*, int, uint32_t, int64_t);
MediaEngineWebRTCVideoSource(webrtc::VideoEngine* videoEnginePtr,
int index, int aFps = 30)
: mVideoEngine(videoEnginePtr)
, mCapIndex(index)
, mWidth(640)
, mHeight(480)
, mState(kReleased)
, mMonitor("WebRTCCamera.Monitor")
, mFps(aFps)
, mInitDone(false)
, mInSnapshotMode(false)
, mSnapshotPath(NULL) { Init(); }
~MediaEngineWebRTCVideoSource() { Shutdown(); }
int index, int aFps = 30);
~MediaEngineWebRTCVideoSource();
virtual void GetName(nsAString&);
virtual void GetUUID(nsAString&);

View File

@ -4,6 +4,8 @@
#include "MediaEngineWebRTC.h"
#include "Layers.h"
#include "ImageTypes.h"
#include "ImageContainer.h"
namespace mozilla {

View File

@ -4,6 +4,7 @@
#include "CameraPreview.h"
#include "Layers.h"
#include "ImageContainer.h"
#define DOM_CAMERA_LOG_LEVEL 3
#include "CameraCommon.h"

View File

@ -27,7 +27,6 @@
#ifdef MOZ_X11
class gfxXlibSurface;
#endif
#include "mozilla/unused.h"
#include "nsGUIEvent.h"
#include "mozilla/unused.h"
@ -368,7 +367,7 @@ private:
// the consistency of the pixels in |mBackground|. A plugin may
// be able to observe partial updates to the background.
nsRefPtr<gfxASurface> mBackground;
nsRefPtr<ImageContainer> mImageContainer;
};

View File

@ -9,7 +9,7 @@
#ifdef MOZ_WIDGET_GONK
#include "mozilla/layers/LayersSurfaces.h"
#include "ImageLayers.h"
#include "ImageContainer.h"
#include <ui/GraphicBuffer.h>

View File

@ -27,6 +27,8 @@ const ViewID FrameMetrics::NULL_SCROLL_ID = 0;
const ViewID FrameMetrics::ROOT_SCROLL_ID = 1;
const ViewID FrameMetrics::START_SCROLL_ID = 2;
PRUint8 gLayerManagerLayerBuilder;
#ifdef MOZ_LAYERS_HAVE_LOG
FILE*
FILEOrDefault(FILE* aFile)

View File

@ -40,7 +40,12 @@ struct PRLogModuleInfo;
class gfxContext;
class nsPaintEvent;
extern PRUint8 gLayerManagerLayerBuilder;
namespace mozilla {
class FrameLayerBuilder;
namespace gl {
class GLContext;
}
@ -82,6 +87,20 @@ public:
virtual ~LayerUserData() {}
};
class LayerManagerLayerBuilder : public LayerUserData {
public:
LayerManagerLayerBuilder(FrameLayerBuilder* aBuilder, bool aDelete = true)
: mLayerBuilder(aBuilder)
, mDelete(aDelete)
{
MOZ_COUNT_CTOR(LayerManagerLayerBuilder);
}
~LayerManagerLayerBuilder();
FrameLayerBuilder* mLayerBuilder;
bool mDelete;
};
/*
* Motivation: For truly smooth animation and video playback, we need to
* be able to compose frames and render them on a dedicated thread (i.e.
@ -186,13 +205,18 @@ public:
* EndTransaction returns.
*/
virtual void BeginTransactionWithTarget(gfxContext* aTarget) = 0;
enum EndTransactionFlags {
END_DEFAULT = 0,
END_NO_IMMEDIATE_REDRAW = 1 << 0, // Do not perform the drawing phase
END_NO_COMPOSITE = 1 << 1 // Do not composite after drawing thebes layer contents.
};
FrameLayerBuilder* GetLayerBuilder() {
LayerManagerLayerBuilder *data = static_cast<LayerManagerLayerBuilder*>(GetUserData(&gLayerManagerLayerBuilder));
return data ? data->mLayerBuilder : nullptr;
}
/**
* Attempts to end an "empty transaction". There must have been no
* changes to the layer tree since the BeginTransaction().

View File

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ReadbackProcessor.h"
#include "ReadbackLayer.h"
namespace mozilla {
namespace layers {

View File

@ -6,13 +6,15 @@
#ifndef GFX_READBACKPROCESSOR_H
#define GFX_READBACKPROCESSOR_H
#include "ReadbackLayer.h"
#include "ThebesLayerBuffer.h"
#include "nsTArray.h"
namespace mozilla {
namespace layers {
class ContainerLayer;
class ReadbackLayer;
class ReadbackProcessor {
public:
/**

View File

@ -10,6 +10,7 @@
#include "ipc/ShadowLayerChild.h"
#include "BasicLayers.h"
#include "BasicImplData.h"
#include "ReadbackLayer.h"
#include "ReadbackProcessor.h"
namespace mozilla {

View File

@ -5,6 +5,7 @@
#include "ReadbackManagerD3D10.h"
#include "ReadbackProcessor.h"
#include "ReadbackLayer.h"
#include "nsIThread.h"
#include "nsThreadUtils.h"

View File

@ -19,6 +19,7 @@
#include "gfxTeeSurface.h"
#include "gfxUtils.h"
#include "ReadbackProcessor.h"
#include "ReadbackLayer.h"
namespace mozilla {
namespace layers {

View File

@ -9,7 +9,6 @@
#include "gfxContext.h"
#include "gfxImageSurface.h"
#include "gfxTypes.h"
#include "gfxUtils.h"
namespace mozilla {
namespace gfx {

View File

@ -32,6 +32,16 @@ using namespace mozilla::layers;
namespace mozilla {
FrameLayerBuilder::DisplayItemData::DisplayItemData(Layer* aLayer, PRUint32 aKey, LayerState aLayerState, PRUint32 aGeneration)
: mLayer(aLayer)
, mDisplayItemKey(aKey)
, mContainerLayerGeneration(aGeneration)
, mLayerState(aLayerState)
{}
FrameLayerBuilder::DisplayItemData::~DisplayItemData()
{}
/**
* This is the userdata we associate with a layer manager.
*/
@ -588,8 +598,6 @@ ThebesDisplayItemLayerUserData* GetThebesDisplayItemLayerUserData(Layer* aLayer)
} // anonymous namespace
PRUint8 gLayerManagerLayerBuilder;
/* static */ void
FrameLayerBuilder::Shutdown()
{
@ -600,12 +608,13 @@ FrameLayerBuilder::Shutdown()
}
void
FrameLayerBuilder::Init(nsDisplayListBuilder* aBuilder)
FrameLayerBuilder::Init(nsDisplayListBuilder* aBuilder, LayerManager* aManager)
{
mRootPresContext = aBuilder->ReferenceFrame()->PresContext()->GetRootPresContext();
if (mRootPresContext) {
mInitialDOMGeneration = mRootPresContext->GetDOMGeneration();
}
aManager->SetUserData(&gLayerManagerLayerBuilder, new LayerManagerLayerBuilder(this));
}
bool
@ -2332,7 +2341,7 @@ FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder,
PRUint32 flags;
bool flattenedLayers = false;
while (true) {
ContainerState state(aBuilder, aManager, GetLayerBuilderForManager(aManager),
ContainerState state(aBuilder, aManager, aManager->GetLayerBuilder(),
aContainerFrame, containerLayer, scaleParameters);
if (flattenedLayers) {
state.SetInvalidateAllThebesContent();
@ -2679,7 +2688,7 @@ FrameLayerBuilder::DrawThebesLayer(ThebesLayer* aLayer,
nsDisplayListBuilder* builder = static_cast<nsDisplayListBuilder*>
(aCallbackData);
FrameLayerBuilder *layerBuilder = GetLayerBuilderForManager(aLayer->Manager());
FrameLayerBuilder *layerBuilder = aLayer->Manager()->GetLayerBuilder();
if (layerBuilder->CheckDOMModified())
return;

View File

@ -11,7 +11,6 @@
#include "nsTArray.h"
#include "nsRegion.h"
#include "nsIFrame.h"
#include "Layers.h"
class nsDisplayListBuilder;
class nsDisplayList;
@ -22,6 +21,7 @@ class nsRootPresContext;
namespace mozilla {
namespace layers {
class ContainerLayer;
class LayerManager;
class ThebesLayer;
}
@ -40,35 +40,6 @@ enum LayerState {
LAYER_SVG_EFFECTS
};
class LayerManagerLayerBuilder : public layers::LayerUserData {
public:
LayerManagerLayerBuilder(FrameLayerBuilder* aBuilder, bool aDelete = true)
: mLayerBuilder(aBuilder)
, mDelete(aDelete)
{
MOZ_COUNT_CTOR(LayerManagerLayerBuilder);
}
~LayerManagerLayerBuilder();
FrameLayerBuilder* mLayerBuilder;
bool mDelete;
};
extern PRUint8 gLayerManagerLayerBuilder;
class ContainerLayerPresContext : public layers::LayerUserData {
public:
nsPresContext* mPresContext;
};
extern PRUint8 gContainerLayerPresContext;
static inline FrameLayerBuilder *GetLayerBuilderForManager(layers::LayerManager* aManager)
{
LayerManagerLayerBuilder *data = static_cast<LayerManagerLayerBuilder*>(aManager->GetUserData(&gLayerManagerLayerBuilder));
return data ? data->mLayerBuilder : nullptr;
}
class RefCountedRegion : public RefCounted<RefCountedRegion> {
public:
nsRegion mRegion;
@ -115,8 +86,8 @@ public:
*/
class FrameLayerBuilder {
public:
typedef layers::ContainerLayer ContainerLayer;
typedef layers::Layer Layer;
typedef layers::ContainerLayer ContainerLayer;
typedef layers::Layer Layer;
typedef layers::ThebesLayer ThebesLayer;
typedef layers::LayerManager LayerManager;
@ -138,7 +109,7 @@ public:
static void Shutdown();
void Init(nsDisplayListBuilder* aBuilder);
void Init(nsDisplayListBuilder* aBuilder, LayerManager* aManager);
/**
* Call this to notify that we have just started a transaction on the
@ -474,12 +445,8 @@ protected:
*/
class DisplayItemData {
public:
DisplayItemData(Layer* aLayer, PRUint32 aKey, LayerState aLayerState, PRUint32 aGeneration)
: mLayer(aLayer)
, mDisplayItemKey(aKey)
, mContainerLayerGeneration(aGeneration)
, mLayerState(aLayerState)
{}
DisplayItemData(Layer* aLayer, PRUint32 aKey, LayerState aLayerState, PRUint32 aGeneration);
~DisplayItemData();
nsRefPtr<Layer> mLayer;
PRUint32 mDisplayItemKey;

View File

@ -984,8 +984,7 @@ void nsDisplayList::PaintForFrame(nsDisplayListBuilder* aBuilder,
}
FrameLayerBuilder *layerBuilder = new FrameLayerBuilder();
layerBuilder->Init(aBuilder);
layerManager->SetUserData(&gLayerManagerLayerBuilder, new LayerManagerLayerBuilder(layerBuilder));
layerBuilder->Init(aBuilder, layerManager);
if (aFlags & PAINT_FLUSH_LAYERS) {
FrameLayerBuilder::InvalidateAllLayers(layerManager);
@ -2379,7 +2378,7 @@ already_AddRefed<Layer>
nsDisplayOpacity::BuildLayer(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
const ContainerParameters& aContainerParameters) {
nsRefPtr<Layer> container = GetLayerBuilderForManager(aManager)->
nsRefPtr<Layer> container = aManager->GetLayerBuilder()->
BuildContainerLayerFor(aBuilder, aManager, mFrame, this, mList,
aContainerParameters, nullptr);
if (!container)
@ -2474,7 +2473,7 @@ already_AddRefed<Layer>
nsDisplayOwnLayer::BuildLayer(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
const ContainerParameters& aContainerParameters) {
nsRefPtr<Layer> layer = GetLayerBuilderForManager(aManager)->
nsRefPtr<Layer> layer = aManager->GetLayerBuilder()->
BuildContainerLayerFor(aBuilder, aManager, mFrame, this, mList,
aContainerParameters, nullptr);
return layer.forget();
@ -2616,7 +2615,7 @@ already_AddRefed<Layer>
nsDisplayScrollLayer::BuildLayer(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
const ContainerParameters& aContainerParameters) {
nsRefPtr<ContainerLayer> layer = GetLayerBuilderForManager(aManager)->
nsRefPtr<ContainerLayer> layer = aManager->GetLayerBuilder()->
BuildContainerLayerFor(aBuilder, aManager, mFrame, this, mList,
aContainerParameters, nullptr);
@ -3400,7 +3399,7 @@ already_AddRefed<Layer> nsDisplayTransform::BuildLayer(nsDisplayListBuilder *aBu
return nullptr;
}
nsRefPtr<ContainerLayer> container = GetLayerBuilderForManager(aManager)->
nsRefPtr<ContainerLayer> container = aManager->GetLayerBuilder()->
BuildContainerLayerFor(aBuilder, aManager, mFrame, this, *mStoredList.GetList(),
aContainerParameters, &newTransformMatrix);
@ -3838,7 +3837,7 @@ nsDisplaySVGEffects::BuildLayer(nsDisplayListBuilder* aBuilder,
return nullptr;
}
nsRefPtr<ContainerLayer> container = GetLayerBuilderForManager(aManager)->
nsRefPtr<ContainerLayer> container = aManager->GetLayerBuilder()->
BuildContainerLayerFor(aBuilder, aManager, mFrame, this, mList,
aContainerParameters, nullptr);

View File

@ -14,6 +14,7 @@
#include "nsHTMLCanvasElement.h"
#include "nsDisplayList.h"
#include "nsLayoutUtils.h"
#include "Layers.h"
#include "nsTransform2D.h"
@ -263,7 +264,7 @@ nsHTMLCanvasFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
return nullptr;
CanvasLayer* oldLayer = static_cast<CanvasLayer*>
(GetLayerBuilderForManager(aManager)->GetLeafLayerFor(aBuilder, aManager, aItem));
(aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aManager, aItem));
nsRefPtr<CanvasLayer> layer = element->GetCanvasLayer(aBuilder, oldLayer, aManager);
if (!layer)
return nullptr;

View File

@ -1646,7 +1646,7 @@ nsObjectFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
// to provide crisper and faster drawing.
r.Round();
nsRefPtr<Layer> layer =
(GetLayerBuilderForManager(aManager)->GetLeafLayerFor(aBuilder, aManager, aItem));
(aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aManager, aItem));
if (aItem->GetType() == nsDisplayItem::TYPE_PLUGIN) {
if (!layer) {

View File

@ -194,7 +194,7 @@ nsVideoFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
container->SetScaleHint(scaleHint);
nsRefPtr<ImageLayer> layer = static_cast<ImageLayer*>
(GetLayerBuilderForManager(aManager)->GetLeafLayerFor(aBuilder, aManager, aItem));
(aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aManager, aItem));
if (!layer) {
layer = aManager->CreateImageLayer();
if (!layer)

View File

@ -626,7 +626,7 @@ RenderFrameParent::BuildLayer(nsDisplayListBuilder* aBuilder,
MOZ_ASSERT(!GetRootLayer());
nsRefPtr<Layer> layer =
(GetLayerBuilderForManager(aManager)->GetLeafLayerFor(aBuilder, aManager, aItem));
(aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aManager, aItem));
if (!layer) {
layer = aManager->CreateRefLayer();
}