Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
/* -*- 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_IMAGEHOST_H
|
|
|
|
#define MOZILLA_GFX_IMAGEHOST_H
|
|
|
|
|
2014-01-06 15:06:04 +00:00
|
|
|
#include <stdio.h> // for FILE
|
2013-08-11 23:17:23 +00:00
|
|
|
#include "CompositableHost.h" // for CompositableHost
|
2015-03-21 16:28:04 +00:00
|
|
|
#include "mozilla/Attributes.h" // for override
|
2015-10-18 05:24:48 +00:00
|
|
|
#include "mozilla/RefPtr.h" // for RefPtr
|
2015-12-02 23:52:00 +00:00
|
|
|
#include "mozilla/gfx/MatrixFwd.h" // for Matrix4x4
|
2013-08-11 23:17:23 +00:00
|
|
|
#include "mozilla/gfx/Point.h" // for Point
|
|
|
|
#include "mozilla/gfx/Rect.h" // for Rect
|
|
|
|
#include "mozilla/gfx/Types.h" // for Filter
|
|
|
|
#include "mozilla/layers/CompositorTypes.h" // for TextureInfo, etc
|
|
|
|
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
|
|
|
|
#include "mozilla/layers/LayersTypes.h" // for LayerRenderState, etc
|
2014-04-03 06:04:04 +00:00
|
|
|
#include "mozilla/layers/TextureHost.h" // for TextureHost, etc
|
2013-08-11 23:17:23 +00:00
|
|
|
#include "mozilla/mozalloc.h" // for operator delete
|
|
|
|
#include "nsCOMPtr.h" // for already_AddRefed
|
2015-05-07 09:07:42 +00:00
|
|
|
#include "nsRect.h" // for mozilla::gfx::IntRect
|
2015-11-04 16:49:49 +00:00
|
|
|
#include "nsRegionFwd.h" // for nsIntRegion
|
2013-08-11 23:17:23 +00:00
|
|
|
#include "nscore.h" // for nsACString
|
2013-11-27 09:59:01 +00:00
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2013-08-11 23:17:23 +00:00
|
|
|
class Compositor;
|
|
|
|
struct EffectChain;
|
2015-07-06 03:02:26 +00:00
|
|
|
class ImageContainerParent;
|
2015-12-29 09:07:33 +00:00
|
|
|
class ImageHostOverlay;
|
2013-07-30 09:59:51 +00:00
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
/**
|
2013-07-30 09:59:51 +00:00
|
|
|
* ImageHost. Works with ImageClientSingle and ImageClientBuffered
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
*/
|
|
|
|
class ImageHost : public CompositableHost
|
|
|
|
{
|
|
|
|
public:
|
2014-08-20 04:55:14 +00:00
|
|
|
explicit ImageHost(const TextureInfo& aTextureInfo);
|
2013-07-30 09:59:51 +00:00
|
|
|
~ImageHost();
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual CompositableType GetType() override { return mTextureInfo.mCompositableType; }
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
|
2015-07-06 03:02:26 +00:00
|
|
|
virtual void Composite(LayerComposite* aLayer,
|
|
|
|
EffectChain& aEffectChain,
|
2013-07-30 09:59:51 +00:00
|
|
|
float aOpacity,
|
|
|
|
const gfx::Matrix4x4& aTransform,
|
|
|
|
const gfx::Filter& aFilter,
|
2016-05-13 23:05:12 +00:00
|
|
|
const gfx::Rect& aClipRect,
|
2015-03-21 16:28:04 +00:00
|
|
|
const nsIntRegion* aVisibleRegion = nullptr) override;
|
2013-07-30 09:59:51 +00:00
|
|
|
|
2015-05-04 10:59:02 +00:00
|
|
|
virtual void UseTextureHost(const nsTArray<TimedTexture>& aTextures) override;
|
2013-07-30 09:59:51 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void RemoveTextureHost(TextureHost* aTexture) override;
|
2014-02-10 20:52:35 +00:00
|
|
|
|
2015-12-29 09:07:33 +00:00
|
|
|
virtual void UseOverlaySource(OverlaySource aOverlay,
|
|
|
|
const gfx::IntRect& aPictureRect) override;
|
|
|
|
|
2015-07-03 22:52:42 +00:00
|
|
|
virtual TextureHost* GetAsTextureHost(gfx::IntRect* aPictureRect = nullptr) override;
|
2013-12-11 18:05:15 +00:00
|
|
|
|
2015-05-04 10:59:02 +00:00
|
|
|
virtual void Attach(Layer* aLayer,
|
|
|
|
Compositor* aCompositor,
|
|
|
|
AttachFlags aFlags = NO_FLAGS) override;
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void SetCompositor(Compositor* aCompositor) override;
|
2013-12-12 01:44:49 +00:00
|
|
|
|
2015-07-06 03:02:26 +00:00
|
|
|
virtual void SetImageContainer(ImageContainerParent* aImageContainer) override;
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
gfx::IntSize GetImageSize() const override;
|
2014-11-12 21:44:42 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual LayerRenderState GetRenderState() override;
|
2013-07-30 09:59:51 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
|
2013-07-30 09:59:51 +00:00
|
|
|
|
2014-06-19 22:36:25 +00:00
|
|
|
virtual void Dump(std::stringstream& aStream,
|
2014-01-06 15:06:04 +00:00
|
|
|
const char* aPrefix = "",
|
2015-03-21 16:28:04 +00:00
|
|
|
bool aDumpHtml = false) override;
|
2013-08-08 12:53:12 +00:00
|
|
|
|
2015-06-17 14:00:52 +00:00
|
|
|
virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override;
|
2013-07-30 09:59:51 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool Lock() override;
|
2014-06-22 17:06:00 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void Unlock() override;
|
2014-06-22 17:06:00 +00:00
|
|
|
|
2015-06-17 14:00:52 +00:00
|
|
|
virtual already_AddRefed<TexturedEffect> GenEffect(const gfx::Filter& aFilter) override;
|
2014-06-22 17:06:00 +00:00
|
|
|
|
2016-02-25 13:15:40 +00:00
|
|
|
void SetCurrentTextureHost(TextureHost* aTexture);
|
|
|
|
|
|
|
|
virtual void CleanupResources() override;
|
|
|
|
|
2015-06-07 09:27:06 +00:00
|
|
|
int32_t GetFrameID()
|
|
|
|
{
|
|
|
|
const TimedImage* img = ChooseImage();
|
|
|
|
return img ? img->mFrameID : -1;
|
|
|
|
}
|
|
|
|
|
2015-08-03 17:36:06 +00:00
|
|
|
int32_t GetProducerID()
|
|
|
|
{
|
|
|
|
const TimedImage* img = ChooseImage();
|
|
|
|
return img ? img->mProducerID : -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t GetLastFrameID() const { return mLastFrameID; }
|
|
|
|
int32_t GetLastProducerID() const { return mLastProducerID; }
|
2016-01-09 02:50:10 +00:00
|
|
|
virtual int32_t GetLastInputFrameID() const override { return mLastInputFrameID; }
|
2015-08-03 17:36:06 +00:00
|
|
|
|
2015-06-15 03:27:02 +00:00
|
|
|
enum Bias {
|
|
|
|
// Don't apply bias to frame times
|
|
|
|
BIAS_NONE,
|
|
|
|
// Apply a negative bias to frame times to keep them before the vsync time
|
|
|
|
BIAS_NEGATIVE,
|
|
|
|
// Apply a positive bias to frame times to keep them after the vsync time
|
|
|
|
BIAS_POSITIVE,
|
|
|
|
};
|
|
|
|
|
2016-04-11 02:51:21 +00:00
|
|
|
bool IsOpaque();
|
|
|
|
|
2013-07-30 09:59:51 +00:00
|
|
|
protected:
|
2015-05-25 10:48:09 +00:00
|
|
|
struct TimedImage {
|
2016-02-25 13:15:40 +00:00
|
|
|
RefPtr<TextureHost> mTextureHost;
|
2015-05-25 10:48:09 +00:00
|
|
|
TimeStamp mTimeStamp;
|
|
|
|
gfx::IntRect mPictureRect;
|
2015-07-06 03:02:26 +00:00
|
|
|
int32_t mFrameID;
|
|
|
|
int32_t mProducerID;
|
2016-01-09 02:50:10 +00:00
|
|
|
int32_t mInputFrameID;
|
2015-05-25 10:48:09 +00:00
|
|
|
};
|
|
|
|
|
2016-02-25 13:15:40 +00:00
|
|
|
CompositableTextureHostRef mCurrentTextureHost;
|
|
|
|
CompositableTextureSourceRef mCurrentTextureSource;
|
|
|
|
// When doing texture uploads it's best to alternate between two (or three)
|
|
|
|
// texture sources so that the texture we upload to isn't being used by
|
|
|
|
// the GPU to composite the previous frame.
|
|
|
|
RefPtr<TextureSource> mExtraTextureSource;
|
|
|
|
|
2015-05-25 10:48:09 +00:00
|
|
|
/**
|
|
|
|
* ChooseImage is guaranteed to return the same TimedImage every time it's
|
2015-06-15 03:27:02 +00:00
|
|
|
* called during the same composition, up to the end of Composite() ---
|
|
|
|
* it depends only on mImages, mCompositor->GetCompositionTime(), and mBias.
|
|
|
|
* mBias is updated at the end of Composite().
|
2015-05-25 10:48:09 +00:00
|
|
|
*/
|
|
|
|
const TimedImage* ChooseImage() const;
|
|
|
|
TimedImage* ChooseImage();
|
|
|
|
int ChooseImageIndex() const;
|
|
|
|
|
|
|
|
nsTArray<TimedImage> mImages;
|
2015-07-06 03:02:26 +00:00
|
|
|
// Weak reference, will be null if mImageContainer has been destroyed.
|
|
|
|
ImageContainerParent* mImageContainer;
|
|
|
|
int32_t mLastFrameID;
|
|
|
|
int32_t mLastProducerID;
|
2016-01-09 02:50:10 +00:00
|
|
|
int32_t mLastInputFrameID;
|
2015-06-15 03:27:02 +00:00
|
|
|
/**
|
|
|
|
* Bias to apply to the next frame.
|
|
|
|
*/
|
|
|
|
Bias mBias;
|
2013-07-30 09:59:51 +00:00
|
|
|
|
2014-06-22 17:06:00 +00:00
|
|
|
bool mLocked;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
|
2015-12-29 09:07:33 +00:00
|
|
|
RefPtr<ImageHostOverlay> mImageHostOverlay;
|
|
|
|
};
|
2014-08-19 02:14:00 +00:00
|
|
|
|
|
|
|
/**
|
2015-12-29 09:07:33 +00:00
|
|
|
* ImageHostOverlay handles OverlaySource compositing
|
2014-08-19 02:14:00 +00:00
|
|
|
*/
|
2015-12-29 09:07:33 +00:00
|
|
|
class ImageHostOverlay {
|
|
|
|
protected:
|
|
|
|
virtual ~ImageHostOverlay();
|
2014-08-19 02:14:00 +00:00
|
|
|
|
2015-12-29 09:07:33 +00:00
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(ImageHostOverlay)
|
|
|
|
ImageHostOverlay();
|
2014-08-19 02:14:00 +00:00
|
|
|
|
2016-01-06 04:50:39 +00:00
|
|
|
static bool IsValid(OverlaySource aOverlay);
|
|
|
|
|
2016-01-19 04:52:32 +00:00
|
|
|
void SetCompositor(Compositor* aCompositor);
|
|
|
|
|
2015-12-29 09:07:33 +00:00
|
|
|
virtual void Composite(Compositor* aCompositor,
|
|
|
|
uint32_t aFlashCounter,
|
|
|
|
LayerComposite* aLayer,
|
2015-07-06 03:02:26 +00:00
|
|
|
EffectChain& aEffectChain,
|
2014-08-19 02:14:00 +00:00
|
|
|
float aOpacity,
|
|
|
|
const gfx::Matrix4x4& aTransform,
|
|
|
|
const gfx::Filter& aFilter,
|
2016-05-13 23:05:12 +00:00
|
|
|
const gfx::Rect& aClipRect,
|
2015-12-29 09:07:33 +00:00
|
|
|
const nsIntRegion* aVisibleRegion);
|
|
|
|
virtual LayerRenderState GetRenderState();
|
2015-07-03 22:52:42 +00:00
|
|
|
virtual void UseOverlaySource(OverlaySource aOverlay,
|
2015-12-29 09:07:33 +00:00
|
|
|
const gfx::IntRect& aPictureRect);
|
|
|
|
virtual gfx::IntSize GetImageSize() const;
|
2014-08-19 02:14:00 +00:00
|
|
|
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix);
|
|
|
|
protected:
|
2016-01-19 04:52:32 +00:00
|
|
|
RefPtr<Compositor> mCompositor;
|
2015-05-07 09:07:42 +00:00
|
|
|
gfx::IntRect mPictureRect;
|
2014-08-19 02:14:00 +00:00
|
|
|
OverlaySource mOverlay;
|
|
|
|
};
|
|
|
|
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
|
|
|
|
#endif
|