2013-04-30 22:03:25 -07: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
|
|
|
|
|
2013-08-11 19:21:17 -07:00
|
|
|
#include "ClientLayerManager.h"
|
|
|
|
#include "nsXULAppAPI.h"
|
|
|
|
#include "gfxASurface.h"
|
|
|
|
#include "mozilla/Preferences.h"
|
|
|
|
#include "mozilla/layers/LayerTransaction.h"
|
|
|
|
#include "mozilla/layers/CanvasClient.h"
|
|
|
|
#include "CopyableCanvasLayer.h"
|
2013-04-30 22:03:25 -07:00
|
|
|
|
|
|
|
using namespace mozilla::gfx;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2013-08-11 19:21:17 -07:00
|
|
|
class CanvasClient2D;
|
|
|
|
class CanvasClientWebGL;
|
2013-04-30 22:03:25 -07:00
|
|
|
|
|
|
|
class ClientCanvasLayer : public CopyableCanvasLayer,
|
|
|
|
public ClientLayer
|
|
|
|
{
|
2013-08-01 18:12:15 -07:00
|
|
|
typedef CanvasClient::CanvasClientType CanvasClientType;
|
2013-04-30 22:03:25 -07:00
|
|
|
public:
|
|
|
|
ClientCanvasLayer(ClientLayerManager* aLayerManager) :
|
|
|
|
CopyableCanvasLayer(aLayerManager, static_cast<ClientLayer*>(this))
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(ClientCanvasLayer);
|
|
|
|
}
|
|
|
|
virtual ~ClientCanvasLayer()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(ClientCanvasLayer);
|
2013-07-30 02:59:51 -07:00
|
|
|
if (mCanvasClient) {
|
2013-08-08 05:53:12 -07:00
|
|
|
mCanvasClient->OnDetach();
|
2013-07-30 02:59:51 -07:00
|
|
|
mCanvasClient = nullptr;
|
|
|
|
}
|
2013-04-30 22:03:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void SetVisibleRegion(const nsIntRegion& aRegion)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(ClientManager()->InConstruction(),
|
|
|
|
"Can only set properties in construction phase");
|
|
|
|
CanvasLayer::SetVisibleRegion(aRegion);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Initialize(const Data& aData);
|
|
|
|
|
|
|
|
virtual void RenderLayer();
|
|
|
|
|
|
|
|
virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
|
|
|
|
{
|
|
|
|
aAttrs = CanvasLayerAttributes(mFilter, mBounds);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual Layer* AsLayer() { return this; }
|
|
|
|
virtual ShadowableLayer* AsShadowableLayer() { return this; }
|
|
|
|
|
|
|
|
virtual void Disconnect()
|
|
|
|
{
|
|
|
|
mCanvasClient = nullptr;
|
|
|
|
ClientLayer::Disconnect();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual CompositableClient* GetCompositableClient() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return mCanvasClient;
|
|
|
|
}
|
|
|
|
protected:
|
|
|
|
ClientLayerManager* ClientManager()
|
|
|
|
{
|
|
|
|
return static_cast<ClientLayerManager*>(mManager);
|
|
|
|
}
|
|
|
|
|
2013-08-01 18:12:15 -07:00
|
|
|
CanvasClientType GetCanvasClientType()
|
2013-04-30 22:03:25 -07:00
|
|
|
{
|
2013-05-27 07:12:13 -07:00
|
|
|
if (mGLContext) {
|
2013-08-01 18:12:15 -07:00
|
|
|
return CanvasClient::CanvasClientGLContext;
|
2013-04-30 22:03:25 -07:00
|
|
|
}
|
2013-08-01 18:12:15 -07:00
|
|
|
return CanvasClient::CanvasClientSurface;
|
2013-04-30 22:03:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<CanvasClient> mCanvasClient;
|
|
|
|
|
2013-08-03 10:29:28 -07:00
|
|
|
friend class DeprecatedCanvasClient2D;
|
2013-08-03 10:29:37 -07:00
|
|
|
friend class CanvasClient2D;
|
2013-08-03 10:29:28 -07:00
|
|
|
friend class DeprecatedCanvasClientSurfaceStream;
|
2013-04-30 22:03:25 -07:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|