2013-05-01 09:03:25 +04:00
|
|
|
/* -*- 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 GFX_CLIENTLAYERMANAGER_H
|
|
|
|
#define GFX_CLIENTLAYERMANAGER_H
|
|
|
|
|
2013-08-12 03:17:23 +04:00
|
|
|
#include <stdint.h> // for int32_t
|
2013-05-01 09:03:25 +04:00
|
|
|
#include "Layers.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "gfxContext.h" // for gfxContext
|
|
|
|
#include "mozilla/Attributes.h" // for MOZ_OVERRIDE
|
2014-03-08 01:34:04 +04:00
|
|
|
#include "mozilla/LinkedList.h" // For LinkedList
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/WidgetUtils.h" // for ScreenRotation
|
|
|
|
#include "mozilla/gfx/Rect.h" // for Rect
|
|
|
|
#include "mozilla/layers/CompositorTypes.h"
|
|
|
|
#include "mozilla/layers/LayersTypes.h" // for BufferMode, LayersBackend, etc
|
|
|
|
#include "mozilla/layers/ShadowLayers.h" // for ShadowLayerForwarder, etc
|
2014-04-22 03:48:54 +04:00
|
|
|
#include "mozilla/layers/APZTestData.h" // for APZTestData
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "nsAutoPtr.h" // for nsRefPtr
|
|
|
|
#include "nsCOMPtr.h" // for already_AddRefed
|
|
|
|
#include "nsDebug.h" // for NS_ABORT_IF_FALSE
|
2014-09-04 19:27:46 +04:00
|
|
|
#include "nsIObserver.h" // for nsIObserver
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "nsISupportsImpl.h" // for Layer::Release, etc
|
|
|
|
#include "nsRect.h" // for nsIntRect
|
|
|
|
#include "nsTArray.h" // for nsTArray
|
|
|
|
#include "nscore.h" // for nsAString
|
2014-05-29 01:43:39 +04:00
|
|
|
#include "mozilla/layers/TransactionIdAllocator.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
|
|
|
|
class nsIWidget;
|
2013-05-01 09:03:25 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2014-09-26 21:06:08 +04:00
|
|
|
class ClientPaintedLayer;
|
2013-08-02 11:04:22 +04:00
|
|
|
class CompositorChild;
|
2013-08-12 03:17:23 +04:00
|
|
|
class ImageLayer;
|
|
|
|
class PLayerChild;
|
2014-03-08 01:34:04 +04:00
|
|
|
class TextureClientPool;
|
|
|
|
|
2014-08-05 21:33:55 +04:00
|
|
|
class ClientLayerManager MOZ_FINAL : public LayerManager
|
2013-05-01 09:03:25 +04:00
|
|
|
{
|
|
|
|
typedef nsTArray<nsRefPtr<Layer> > LayerRefArray;
|
|
|
|
|
|
|
|
public:
|
2014-08-20 08:55:14 +04:00
|
|
|
explicit ClientLayerManager(nsIWidget* aWidget);
|
2014-07-15 19:37:45 +04:00
|
|
|
|
2014-09-04 02:55:00 +04:00
|
|
|
virtual void Destroy()
|
|
|
|
{
|
|
|
|
LayerManager::Destroy();
|
|
|
|
ClearCachedResources();
|
|
|
|
}
|
|
|
|
|
2014-07-15 19:37:45 +04:00
|
|
|
protected:
|
2013-05-01 09:03:25 +04:00
|
|
|
virtual ~ClientLayerManager();
|
|
|
|
|
2014-07-15 19:37:45 +04:00
|
|
|
public:
|
2013-05-01 09:03:25 +04:00
|
|
|
virtual ShadowLayerForwarder* AsShadowForwarder()
|
|
|
|
{
|
2013-11-27 19:19:34 +04:00
|
|
|
return mForwarder;
|
2013-05-01 09:03:25 +04:00
|
|
|
}
|
|
|
|
|
2014-06-18 06:42:34 +04:00
|
|
|
virtual ClientLayerManager* AsClientLayerManager()
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2013-05-01 09:03:25 +04:00
|
|
|
virtual int32_t GetMaxTextureSize() const;
|
|
|
|
|
|
|
|
virtual void SetDefaultTargetConfiguration(BufferMode aDoubleBuffering, ScreenRotation aRotation);
|
|
|
|
virtual void BeginTransactionWithTarget(gfxContext* aTarget);
|
|
|
|
virtual void BeginTransaction();
|
|
|
|
virtual bool EndEmptyTransaction(EndTransactionFlags aFlags = END_DEFAULT);
|
2014-09-26 21:06:08 +04:00
|
|
|
virtual void EndTransaction(DrawPaintedLayerCallback aCallback,
|
2013-05-01 09:03:25 +04:00
|
|
|
void* aCallbackData,
|
|
|
|
EndTransactionFlags aFlags = END_DEFAULT);
|
|
|
|
|
2014-01-23 22:26:41 +04:00
|
|
|
virtual LayersBackend GetBackendType() { return LayersBackend::LAYERS_CLIENT; }
|
2014-04-07 07:11:17 +04:00
|
|
|
virtual LayersBackend GetCompositorBackendType() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return AsShadowForwarder()->GetCompositorBackendType();
|
|
|
|
}
|
2013-05-01 09:03:25 +04:00
|
|
|
virtual void GetBackendName(nsAString& name);
|
2013-05-10 01:02:49 +04:00
|
|
|
virtual const char* Name() const { return "Client"; }
|
2013-05-01 09:03:25 +04:00
|
|
|
|
|
|
|
virtual void SetRoot(Layer* aLayer);
|
|
|
|
|
|
|
|
virtual void Mutated(Layer* aLayer);
|
|
|
|
|
2014-09-26 21:06:08 +04:00
|
|
|
virtual bool IsOptimizedFor(PaintedLayer* aLayer, PaintedLayerCreationHint aHint);
|
2014-06-13 20:11:08 +04:00
|
|
|
|
2014-09-26 21:06:08 +04:00
|
|
|
virtual already_AddRefed<PaintedLayer> CreatePaintedLayer();
|
|
|
|
virtual already_AddRefed<PaintedLayer> CreatePaintedLayerWithHint(PaintedLayerCreationHint aHint);
|
2013-05-01 09:03:25 +04:00
|
|
|
virtual already_AddRefed<ContainerLayer> CreateContainerLayer();
|
|
|
|
virtual already_AddRefed<ImageLayer> CreateImageLayer();
|
|
|
|
virtual already_AddRefed<CanvasLayer> CreateCanvasLayer();
|
2014-07-30 17:38:47 +04:00
|
|
|
virtual already_AddRefed<ReadbackLayer> CreateReadbackLayer();
|
2013-05-01 09:03:25 +04:00
|
|
|
virtual already_AddRefed<ColorLayer> CreateColorLayer();
|
|
|
|
virtual already_AddRefed<RefLayer> CreateRefLayer();
|
|
|
|
|
2013-12-09 05:40:59 +04:00
|
|
|
TextureFactoryIdentifier GetTextureFactoryIdentifier()
|
2013-07-12 06:32:09 +04:00
|
|
|
{
|
2013-11-27 19:19:34 +04:00
|
|
|
return mForwarder->GetTextureFactoryIdentifier();
|
2013-07-12 06:32:09 +04:00
|
|
|
}
|
|
|
|
|
2013-06-18 11:58:43 +04:00
|
|
|
virtual void FlushRendering() MOZ_OVERRIDE;
|
2013-11-21 23:25:16 +04:00
|
|
|
void SendInvalidRegion(const nsIntRegion& aRegion);
|
2013-06-18 11:58:43 +04:00
|
|
|
|
2013-11-27 11:32:19 +04:00
|
|
|
virtual uint32_t StartFrameTimeRecording(int32_t aBufferSize) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual void StopFrameTimeRecording(uint32_t aStartIndex,
|
|
|
|
nsTArray<float>& aFrameIntervals) MOZ_OVERRIDE;
|
|
|
|
|
2013-07-09 08:21:05 +04:00
|
|
|
virtual bool NeedsWidgetInvalidation() MOZ_OVERRIDE { return false; }
|
2013-06-18 11:59:29 +04:00
|
|
|
|
2013-05-01 09:03:25 +04:00
|
|
|
ShadowableLayer* Hold(Layer* aLayer);
|
|
|
|
|
2013-11-27 19:19:34 +04:00
|
|
|
bool HasShadowManager() const { return mForwarder->HasShadowManager(); }
|
2013-05-01 09:03:25 +04:00
|
|
|
|
|
|
|
virtual bool IsCompositingCheap();
|
|
|
|
virtual bool HasShadowManagerInternal() const { return HasShadowManager(); }
|
|
|
|
|
|
|
|
virtual void SetIsFirstPaint() MOZ_OVERRIDE;
|
|
|
|
|
2014-06-18 06:42:34 +04:00
|
|
|
TextureClientPool* GetTexturePool(gfx::SurfaceFormat aFormat);
|
2014-03-08 01:34:04 +04:00
|
|
|
|
2014-09-16 18:07:46 +04:00
|
|
|
/// Utility methods for managing texture clients.
|
|
|
|
void ReturnTextureClientDeferred(TextureClient& aClient);
|
|
|
|
void ReturnTextureClient(TextureClient& aClient);
|
|
|
|
void ReportClientLost(TextureClient& aClient);
|
|
|
|
|
2013-05-01 09:03:25 +04:00
|
|
|
// Drop cached resources and ask our shadow manager to do the same,
|
|
|
|
// if we have one.
|
|
|
|
virtual void ClearCachedResources(Layer* aSubtree = nullptr) MOZ_OVERRIDE;
|
|
|
|
|
2014-09-04 19:27:46 +04:00
|
|
|
void HandleMemoryPressure();
|
|
|
|
|
2013-05-01 09:03:25 +04:00
|
|
|
void SetRepeatTransaction() { mRepeatTransaction = true; }
|
|
|
|
bool GetRepeatTransaction() { return mRepeatTransaction; }
|
|
|
|
|
|
|
|
bool IsRepeatTransaction() { return mIsRepeatTransaction; }
|
|
|
|
|
|
|
|
void SetTransactionIncomplete() { mTransactionIncomplete = true; }
|
|
|
|
|
2013-05-10 01:02:50 +04:00
|
|
|
bool HasShadowTarget() { return !!mShadowTarget; }
|
|
|
|
|
2014-06-18 06:42:34 +04:00
|
|
|
void SetShadowTarget(gfxContext* aTarget) { mShadowTarget = aTarget; }
|
2013-05-01 09:03:25 +04:00
|
|
|
|
|
|
|
bool CompositorMightResample() { return mCompositorMightResample; }
|
|
|
|
|
2014-09-26 21:06:08 +04:00
|
|
|
DrawPaintedLayerCallback GetPaintedLayerCallback() const
|
|
|
|
{ return mPaintedLayerCallback; }
|
2013-05-01 09:03:25 +04:00
|
|
|
|
2014-09-26 21:06:08 +04:00
|
|
|
void* GetPaintedLayerCallbackData() const
|
|
|
|
{ return mPaintedLayerCallbackData; }
|
2013-05-01 09:03:25 +04:00
|
|
|
|
2014-06-18 06:42:34 +04:00
|
|
|
CompositorChild* GetRemoteRenderer();
|
|
|
|
|
|
|
|
CompositorChild* GetCompositorChild();
|
2013-07-12 06:32:09 +04:00
|
|
|
|
2014-07-18 10:48:22 +04:00
|
|
|
// Disable component alpha layers with the software compositor.
|
2014-07-18 10:48:23 +04:00
|
|
|
virtual bool ShouldAvoidComponentAlphaLayers() { return !IsCompositingCheap(); }
|
2014-07-18 10:48:22 +04:00
|
|
|
|
2013-05-01 09:03:25 +04:00
|
|
|
/**
|
2014-06-23 16:42:53 +04:00
|
|
|
* Called for each iteration of a progressive tile update. Updates
|
|
|
|
* aMetrics with the current scroll offset and scale being used to composite
|
|
|
|
* the primary scrollable layer in this manager, to determine what area
|
2013-11-27 21:33:27 +04:00
|
|
|
* intersects with the target composition bounds.
|
|
|
|
* aDrawingCritical will be true if the current drawing operation is using
|
|
|
|
* the critical displayport.
|
2013-05-01 09:03:25 +04:00
|
|
|
* Returns true if the update should continue, or false if it should be
|
|
|
|
* cancelled.
|
|
|
|
* This is only called if gfxPlatform::UseProgressiveTilePainting() returns
|
|
|
|
* true.
|
|
|
|
*/
|
|
|
|
bool ProgressiveUpdateCallback(bool aHasPendingNewThebesContent,
|
2014-06-23 16:42:53 +04:00
|
|
|
FrameMetrics& aMetrics,
|
2013-05-01 09:03:25 +04:00
|
|
|
bool aDrawingCritical);
|
|
|
|
|
|
|
|
bool InConstruction() { return mPhase == PHASE_CONSTRUCTION; }
|
2014-02-22 01:50:25 +04:00
|
|
|
#ifdef DEBUG
|
2013-05-01 09:03:25 +04:00
|
|
|
bool InDrawing() { return mPhase == PHASE_DRAWING; }
|
|
|
|
bool InForward() { return mPhase == PHASE_FORWARD; }
|
|
|
|
#endif
|
|
|
|
bool InTransaction() { return mPhase != PHASE_NONE; }
|
|
|
|
|
2013-10-22 00:14:47 +04:00
|
|
|
void SetNeedsComposite(bool aNeedsComposite)
|
|
|
|
{
|
|
|
|
mNeedsComposite = aNeedsComposite;
|
|
|
|
}
|
|
|
|
bool NeedsComposite() const { return mNeedsComposite; }
|
|
|
|
|
2013-12-16 09:38:42 +04:00
|
|
|
virtual void Composite() MOZ_OVERRIDE;
|
2014-05-08 19:32:00 +04:00
|
|
|
virtual bool RequestOverfill(mozilla::dom::OverfillCallback* aCallback) MOZ_OVERRIDE;
|
|
|
|
virtual void RunOverfillCallback(const uint32_t aOverfill) MOZ_OVERRIDE;
|
2013-12-16 09:38:42 +04:00
|
|
|
|
2014-05-29 01:42:14 +04:00
|
|
|
virtual void DidComposite(uint64_t aTransactionId);
|
2014-03-07 07:24:32 +04:00
|
|
|
|
2014-05-09 13:48:32 +04:00
|
|
|
virtual bool SupportsMixBlendModes(EnumSet<gfx::CompositionOp>& aMixBlendModes) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return (GetTextureFactoryIdentifier().mSupportedBlendModes & aMixBlendModes) == aMixBlendModes;
|
|
|
|
}
|
|
|
|
|
2014-07-18 10:48:23 +04:00
|
|
|
virtual bool AreComponentAlphaLayersEnabled() MOZ_OVERRIDE;
|
|
|
|
|
2014-04-22 03:48:54 +04:00
|
|
|
// Log APZ test data for the current paint. We supply the paint sequence
|
|
|
|
// number ourselves, and take care of calling APZTestData::StartNewPaint()
|
|
|
|
// when a new paint is started.
|
|
|
|
void LogTestDataForCurrentPaint(FrameMetrics::ViewID aScrollId,
|
|
|
|
const std::string& aKey,
|
|
|
|
const std::string& aValue)
|
|
|
|
{
|
|
|
|
mApzTestData.LogTestDataForPaint(mPaintSequenceNumber, aScrollId, aKey, aValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Log APZ test data for a repaint request. The sequence number must be
|
|
|
|
// passed in from outside, and APZTestData::StartNewRepaintRequest() needs
|
|
|
|
// to be called from the outside as well when a new repaint request is started.
|
2014-07-24 02:38:28 +04:00
|
|
|
void StartNewRepaintRequest(SequenceNumber aSequenceNumber);
|
|
|
|
|
2014-05-29 20:51:28 +04:00
|
|
|
// TODO(botond): When we start using this and write a wrapper similar to
|
|
|
|
// nsLayoutUtils::LogTestDataForPaint(), make sure that wrapper checks
|
|
|
|
// gfxPrefs::APZTestLoggingEnabled().
|
2014-04-22 03:48:54 +04:00
|
|
|
void LogTestDataForRepaintRequest(SequenceNumber aSequenceNumber,
|
|
|
|
FrameMetrics::ViewID aScrollId,
|
|
|
|
const std::string& aKey,
|
|
|
|
const std::string& aValue)
|
|
|
|
{
|
|
|
|
mApzTestData.LogTestDataForRepaintRequest(aSequenceNumber, aScrollId, aKey, aValue);
|
|
|
|
}
|
|
|
|
|
2014-05-10 01:16:03 +04:00
|
|
|
// Get the content-side APZ test data for reading. For writing, use the
|
|
|
|
// LogTestData...() functions.
|
|
|
|
const APZTestData& GetAPZTestData() const {
|
|
|
|
return mApzTestData;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get a copy of the compositor-side APZ test data for our layers ID.
|
|
|
|
void GetCompositorSideAPZTestData(APZTestData* aData) const;
|
|
|
|
|
2014-05-29 01:43:39 +04:00
|
|
|
void SetTransactionIdAllocator(TransactionIdAllocator* aAllocator) { mTransactionIdAllocator = aAllocator; }
|
|
|
|
|
2014-09-02 23:23:34 +04:00
|
|
|
float RequestProperty(const nsAString& aProperty) MOZ_OVERRIDE;
|
2013-05-01 09:03:25 +04:00
|
|
|
protected:
|
|
|
|
enum TransactionPhase {
|
|
|
|
PHASE_NONE, PHASE_CONSTRUCTION, PHASE_DRAWING, PHASE_FORWARD
|
|
|
|
};
|
|
|
|
TransactionPhase mPhase;
|
|
|
|
|
|
|
|
private:
|
2014-09-04 19:27:46 +04:00
|
|
|
// Listen memory-pressure event for ClientLayerManager
|
|
|
|
class MemoryPressureObserver MOZ_FINAL : public nsIObserver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
2014-09-09 04:48:12 +04:00
|
|
|
explicit MemoryPressureObserver(ClientLayerManager* aClientLayerManager)
|
2014-09-04 19:27:46 +04:00
|
|
|
: mClientLayerManager(aClientLayerManager)
|
|
|
|
{
|
|
|
|
RegisterMemoryPressureEvent();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Destroy();
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual ~MemoryPressureObserver() {}
|
|
|
|
void RegisterMemoryPressureEvent();
|
|
|
|
void UnregisterMemoryPressureEvent();
|
|
|
|
|
|
|
|
ClientLayerManager* mClientLayerManager;
|
|
|
|
};
|
|
|
|
|
2013-05-01 09:03:25 +04:00
|
|
|
/**
|
|
|
|
* Forward transaction results to the parent context.
|
|
|
|
*/
|
2013-12-16 09:38:42 +04:00
|
|
|
void ForwardTransaction(bool aScheduleComposite);
|
2013-05-01 09:03:25 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Take a snapshot of the parent context, and copy
|
|
|
|
* it into mShadowTarget.
|
|
|
|
*/
|
|
|
|
void MakeSnapshotIfRequired();
|
|
|
|
|
|
|
|
void ClearLayer(Layer* aLayer);
|
|
|
|
|
2014-09-26 21:06:08 +04:00
|
|
|
bool EndTransactionInternal(DrawPaintedLayerCallback aCallback,
|
2013-05-01 09:03:25 +04:00
|
|
|
void* aCallbackData,
|
|
|
|
EndTransactionFlags);
|
|
|
|
|
|
|
|
LayerRefArray mKeepAlive;
|
|
|
|
|
|
|
|
nsIWidget* mWidget;
|
|
|
|
|
2014-09-26 21:07:06 +04:00
|
|
|
/* PaintedLayer callbacks; valid at the end of a transaciton,
|
2013-05-01 09:03:25 +04:00
|
|
|
* while rendering */
|
2014-09-26 21:06:08 +04:00
|
|
|
DrawPaintedLayerCallback mPaintedLayerCallback;
|
|
|
|
void *mPaintedLayerCallbackData;
|
2013-05-01 09:03:25 +04:00
|
|
|
|
|
|
|
// When we're doing a transaction in order to draw to a non-default
|
|
|
|
// target, the layers transaction is only performed in order to send
|
|
|
|
// a PLayers:Update. We save the original non-default target to
|
|
|
|
// mShadowTarget, and then perform the transaction using
|
|
|
|
// mDummyTarget as the render target. After the transaction ends,
|
|
|
|
// we send a message to our remote side to capture the actual pixels
|
|
|
|
// being drawn to the default target, and then copy those pixels
|
|
|
|
// back to mShadowTarget.
|
|
|
|
nsRefPtr<gfxContext> mShadowTarget;
|
|
|
|
|
2014-05-29 01:43:39 +04:00
|
|
|
nsRefPtr<TransactionIdAllocator> mTransactionIdAllocator;
|
2014-05-29 01:44:30 +04:00
|
|
|
uint64_t mLatestTransactionId;
|
2014-05-29 01:43:39 +04:00
|
|
|
|
2013-05-01 09:03:25 +04:00
|
|
|
// Sometimes we draw to targets that don't natively support
|
|
|
|
// landscape/portrait orientation. When we need to implement that
|
|
|
|
// ourselves, |mTargetRotation| describes the induced transform we
|
|
|
|
// need to apply when compositing content to our target.
|
|
|
|
ScreenRotation mTargetRotation;
|
|
|
|
|
|
|
|
// Used to repeat the transaction right away (to avoid rebuilding
|
|
|
|
// a display list) to support progressive drawing.
|
|
|
|
bool mRepeatTransaction;
|
|
|
|
bool mIsRepeatTransaction;
|
|
|
|
bool mTransactionIncomplete;
|
|
|
|
bool mCompositorMightResample;
|
2013-10-22 00:14:47 +04:00
|
|
|
bool mNeedsComposite;
|
2013-11-27 19:19:34 +04:00
|
|
|
|
2014-05-07 01:26:13 +04:00
|
|
|
// An incrementing sequence number for paints.
|
|
|
|
// Incremented in BeginTransaction(), but not for repeat transactions.
|
|
|
|
uint32_t mPaintSequenceNumber;
|
|
|
|
|
2014-04-22 03:48:54 +04:00
|
|
|
APZTestData mApzTestData;
|
|
|
|
|
2013-11-27 19:19:34 +04:00
|
|
|
RefPtr<ShadowLayerForwarder> mForwarder;
|
2014-03-18 08:06:25 +04:00
|
|
|
nsAutoTArray<RefPtr<TextureClientPool>,2> mTexturePools;
|
2014-05-08 19:32:00 +04:00
|
|
|
nsAutoTArray<dom::OverfillCallback*,0> mOverfillCallbacks;
|
2014-08-28 23:24:26 +04:00
|
|
|
mozilla::TimeStamp mTransactionStart;
|
2014-03-10 22:34:57 +04:00
|
|
|
|
2014-09-04 19:27:46 +04:00
|
|
|
nsRefPtr<MemoryPressureObserver> mMemoryPressureObserver;
|
2013-05-01 09:03:25 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
class ClientLayer : public ShadowableLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ClientLayer()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(ClientLayer);
|
|
|
|
}
|
|
|
|
|
|
|
|
~ClientLayer();
|
|
|
|
|
|
|
|
void SetShadow(PLayerChild* aShadow)
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(!mShadow, "can't have two shadows (yet)");
|
|
|
|
mShadow = aShadow;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Disconnect()
|
|
|
|
{
|
|
|
|
// This is an "emergency Disconnect()", called when the compositing
|
|
|
|
// process has died. |mShadow| and our Shmem buffers are
|
|
|
|
// automatically managed by IPDL, so we don't need to explicitly
|
|
|
|
// free them here (it's hard to get that right on emergency
|
|
|
|
// shutdown anyway).
|
|
|
|
mShadow = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void ClearCachedResources() { }
|
|
|
|
|
|
|
|
virtual void RenderLayer() = 0;
|
2014-08-07 03:55:31 +04:00
|
|
|
virtual void RenderLayerWithReadback(ReadbackProcessor *aReadback) { RenderLayer(); }
|
2013-05-01 09:03:25 +04:00
|
|
|
|
2014-09-26 21:06:08 +04:00
|
|
|
virtual ClientPaintedLayer* AsThebes() { return nullptr; }
|
2013-05-01 09:03:25 +04:00
|
|
|
|
|
|
|
static inline ClientLayer *
|
|
|
|
ToClientLayer(Layer* aLayer)
|
|
|
|
{
|
|
|
|
return static_cast<ClientLayer*>(aLayer->ImplData());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Create a shadow layer (PLayerChild) for aLayer, if we're forwarding
|
|
|
|
// our layer tree to a parent process. Record the new layer creation
|
|
|
|
// in the current open transaction as a side effect.
|
|
|
|
template<typename CreatedMethod> void
|
|
|
|
CreateShadowFor(ClientLayer* aLayer,
|
|
|
|
ClientLayerManager* aMgr,
|
|
|
|
CreatedMethod aMethod)
|
|
|
|
{
|
2013-11-27 19:19:34 +04:00
|
|
|
PLayerChild* shadow = aMgr->AsShadowForwarder()->ConstructShadowFor(aLayer);
|
2013-05-01 09:03:25 +04:00
|
|
|
// XXX error handling
|
|
|
|
NS_ABORT_IF_FALSE(shadow, "failed to create shadow");
|
|
|
|
|
|
|
|
aLayer->SetShadow(shadow);
|
2013-11-27 19:19:34 +04:00
|
|
|
(aMgr->AsShadowForwarder()->*aMethod)(aLayer);
|
2013-05-01 09:03:25 +04:00
|
|
|
aMgr->Hold(aLayer->AsLayer());
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CREATE_SHADOW(_type) \
|
|
|
|
CreateShadowFor(layer, this, \
|
|
|
|
&ShadowLayerForwarder::Created ## _type ## Layer)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* GFX_CLIENTLAYERMANAGER_H */
|