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_CLIENTCANVASLAYER_H
|
|
|
|
#define GFX_CLIENTCANVASLAYER_H
|
|
|
|
|
2015-06-05 03:15:38 +03:00
|
|
|
#include "CanvasClient.h" // for CanvasClient, etc
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "ClientLayerManager.h" // for ClientLayerManager, etc
|
|
|
|
#include "CopyableCanvasLayer.h" // for CopyableCanvasLayer
|
|
|
|
#include "Layers.h" // for CanvasLayer, etc
|
2015-03-21 19:28:04 +03:00
|
|
|
#include "mozilla/Attributes.h" // for override
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/RefPtr.h" // for RefPtr
|
2013-09-06 19:41:00 +04:00
|
|
|
#include "mozilla/layers/LayersMessages.h" // for CanvasLayerAttributes, etc
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/mozalloc.h" // for operator delete
|
|
|
|
#include "nsAutoPtr.h" // for nsRefPtr
|
|
|
|
#include "nsDebug.h" // for NS_ASSERTION
|
2014-02-27 01:36:35 +04:00
|
|
|
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "nsRegion.h" // for nsIntRegion
|
2013-05-01 09:03:25 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2014-07-12 02:10:49 +04:00
|
|
|
namespace gl {
|
|
|
|
class SurfaceFactory;
|
|
|
|
}
|
|
|
|
|
2013-05-01 09:03:25 +04:00
|
|
|
namespace layers {
|
|
|
|
|
2013-08-12 03:17:23 +04:00
|
|
|
class CompositableClient;
|
|
|
|
class ShadowableLayer;
|
2013-05-01 09:03:25 +04:00
|
|
|
|
|
|
|
class ClientCanvasLayer : public CopyableCanvasLayer,
|
|
|
|
public ClientLayer
|
|
|
|
{
|
2013-08-02 05:12:15 +04:00
|
|
|
typedef CanvasClient::CanvasClientType CanvasClientType;
|
2013-05-01 09:03:25 +04:00
|
|
|
public:
|
2014-08-20 08:55:14 +04:00
|
|
|
explicit ClientCanvasLayer(ClientLayerManager* aLayerManager) :
|
2015-01-07 08:39:46 +03:00
|
|
|
CopyableCanvasLayer(aLayerManager, static_cast<ClientLayer*>(this))
|
2013-05-01 09:03:25 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(ClientCanvasLayer);
|
|
|
|
}
|
2014-07-15 19:37:45 +04:00
|
|
|
|
|
|
|
protected:
|
2014-03-06 01:49:37 +04:00
|
|
|
virtual ~ClientCanvasLayer();
|
2013-05-01 09:03:25 +04:00
|
|
|
|
2014-07-15 19:37:45 +04:00
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void SetVisibleRegion(const nsIntRegion& aRegion) override
|
2013-05-01 09:03:25 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(ClientManager()->InConstruction(),
|
|
|
|
"Can only set properties in construction phase");
|
|
|
|
CanvasLayer::SetVisibleRegion(aRegion);
|
|
|
|
}
|
2014-01-10 17:06:06 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void Initialize(const Data& aData) override;
|
2013-05-01 09:03:25 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void RenderLayer() override;
|
2014-01-10 17:06:06 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ClearCachedResources() override
|
2014-02-27 01:41:17 +04:00
|
|
|
{
|
|
|
|
if (mCanvasClient) {
|
|
|
|
mCanvasClient->Clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs) override
|
2013-05-01 09:03:25 +04:00
|
|
|
{
|
|
|
|
aAttrs = CanvasLayerAttributes(mFilter, mBounds);
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual Layer* AsLayer() override { return this; }
|
|
|
|
virtual ShadowableLayer* AsShadowableLayer() override { return this; }
|
2014-01-10 17:06:06 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void Disconnect() override
|
2013-05-01 09:03:25 +04:00
|
|
|
{
|
|
|
|
mCanvasClient = nullptr;
|
|
|
|
ClientLayer::Disconnect();
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual CompositableClient* GetCompositableClient() override
|
2013-05-01 09:03:25 +04:00
|
|
|
{
|
|
|
|
return mCanvasClient;
|
|
|
|
}
|
2015-06-05 03:15:38 +03:00
|
|
|
|
|
|
|
const TextureFlags& Flags() const { return mFlags; }
|
|
|
|
|
2013-05-01 09:03:25 +04:00
|
|
|
protected:
|
|
|
|
ClientLayerManager* ClientManager()
|
|
|
|
{
|
|
|
|
return static_cast<ClientLayerManager*>(mManager);
|
|
|
|
}
|
2014-01-10 17:06:06 +04:00
|
|
|
|
2014-10-08 08:01:51 +04:00
|
|
|
CanvasClientType GetCanvasClientType();
|
2013-05-01 09:03:25 +04:00
|
|
|
|
|
|
|
RefPtr<CanvasClient> mCanvasClient;
|
|
|
|
|
2014-08-16 04:38:08 +04:00
|
|
|
UniquePtr<gl::SurfaceFactory> mFactory;
|
2014-03-06 01:49:37 +04:00
|
|
|
|
2015-06-05 03:15:38 +03:00
|
|
|
TextureFlags mFlags;
|
|
|
|
|
2013-08-03 21:29:28 +04:00
|
|
|
friend class DeprecatedCanvasClient2D;
|
2013-08-03 21:29:37 +04:00
|
|
|
friend class CanvasClient2D;
|
2014-10-08 08:11:54 +04:00
|
|
|
friend class CanvasClientSharedSurface;
|
2013-05-01 09:03:25 +04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|