1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef GFX_CLIENTCANVASLAYER_H
7 #define GFX_CLIENTCANVASLAYER_H
9 #include "mozilla/layers/CanvasClient.h" // for CanvasClient, etc
10 #include "ClientLayerManager.h" // for ClientLayerManager, etc
11 #include "CopyableCanvasLayer.h" // for CopyableCanvasLayer
12 #include "Layers.h" // for CanvasLayer, etc
13 #include "mozilla/Attributes.h" // for MOZ_OVERRIDE
14 #include "mozilla/RefPtr.h" // for RefPtr
15 #include "mozilla/layers/LayersMessages.h" // for CanvasLayerAttributes, etc
16 #include "mozilla/mozalloc.h" // for operator delete
17 #include "nsAutoPtr.h" // for nsRefPtr
18 #include "nsDebug.h" // for NS_ASSERTION
19 #include "nsRegion.h" // for nsIntRegion
20 #include "nsTraceRefcnt.h" // for MOZ_COUNT_CTOR, etc
22 using namespace mozilla::gfx
;
27 class CompositableClient
;
28 class ShadowableLayer
;
30 class ClientCanvasLayer
: public CopyableCanvasLayer
,
33 typedef CanvasClient::CanvasClientType CanvasClientType
;
35 ClientCanvasLayer(ClientLayerManager
* aLayerManager
) :
36 CopyableCanvasLayer(aLayerManager
,
37 static_cast<ClientLayer
*>(MOZ_THIS_IN_INITIALIZER_LIST()))
39 MOZ_COUNT_CTOR(ClientCanvasLayer
);
41 virtual ~ClientCanvasLayer()
43 MOZ_COUNT_DTOR(ClientCanvasLayer
);
45 mCanvasClient
->OnDetach();
46 mCanvasClient
= nullptr;
50 virtual void SetVisibleRegion(const nsIntRegion
& aRegion
)
52 NS_ASSERTION(ClientManager()->InConstruction(),
53 "Can only set properties in construction phase");
54 CanvasLayer::SetVisibleRegion(aRegion
);
57 virtual void Initialize(const Data
& aData
);
59 virtual void RenderLayer();
61 virtual void FillSpecificAttributes(SpecificLayerAttributes
& aAttrs
)
63 aAttrs
= CanvasLayerAttributes(mFilter
, mBounds
);
66 virtual Layer
* AsLayer() { return this; }
67 virtual ShadowableLayer
* AsShadowableLayer() { return this; }
69 virtual void Disconnect()
71 mCanvasClient
= nullptr;
72 ClientLayer::Disconnect();
75 virtual CompositableClient
* GetCompositableClient() MOZ_OVERRIDE
80 ClientLayerManager
* ClientManager()
82 return static_cast<ClientLayerManager
*>(mManager
);
85 CanvasClientType
GetCanvasClientType()
88 return CanvasClient::CanvasClientGLContext
;
90 return CanvasClient::CanvasClientSurface
;
93 RefPtr
<CanvasClient
> mCanvasClient
;
95 friend class DeprecatedCanvasClient2D
;
96 friend class CanvasClient2D
;
97 friend class DeprecatedCanvasClientSurfaceStream
;