Line data Source code
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/. */
5 :
6 : #include "ClientLayerManager.h" // for ClientLayerManager, etc
7 : #include "Layers.h" // for ColorLayer, etc
8 : #include "mozilla/layers/LayersMessages.h" // for ColorLayerAttributes, etc
9 : #include "mozilla/mozalloc.h" // for operator new
10 : #include "nsCOMPtr.h" // for already_AddRefed
11 : #include "nsDebug.h" // for NS_ASSERTION
12 : #include "nsISupportsImpl.h" // for Layer::AddRef, etc
13 : #include "nsRegion.h" // for nsIntRegion
14 :
15 : namespace mozilla {
16 : namespace layers {
17 :
18 : using namespace mozilla::gfx;
19 :
20 : class ClientBorderLayer : public BorderLayer,
21 : public ClientLayer {
22 : public:
23 0 : explicit ClientBorderLayer(ClientLayerManager* aLayerManager) :
24 0 : BorderLayer(aLayerManager, static_cast<ClientLayer*>(this))
25 : {
26 0 : MOZ_COUNT_CTOR(ClientBorderLayer);
27 0 : }
28 :
29 : protected:
30 0 : virtual ~ClientBorderLayer()
31 0 : {
32 0 : MOZ_COUNT_DTOR(ClientBorderLayer);
33 0 : }
34 :
35 : public:
36 0 : virtual void SetVisibleRegion(const LayerIntRegion& aRegion)
37 : {
38 0 : NS_ASSERTION(ClientManager()->InConstruction(),
39 : "Can only set properties in construction phase");
40 0 : BorderLayer::SetVisibleRegion(aRegion);
41 0 : }
42 :
43 0 : virtual void RenderLayer()
44 : {
45 0 : RenderMaskLayers(this);
46 0 : }
47 :
48 0 : virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
49 : {
50 0 : aAttrs = BorderLayerAttributes(mRect, mColors, mCorners, mWidths);
51 0 : }
52 :
53 0 : virtual Layer* AsLayer() { return this; }
54 0 : virtual ShadowableLayer* AsShadowableLayer() { return this; }
55 :
56 : protected:
57 0 : ClientLayerManager* ClientManager()
58 : {
59 0 : return static_cast<ClientLayerManager*>(mManager);
60 : }
61 : };
62 :
63 : already_AddRefed<BorderLayer>
64 0 : ClientLayerManager::CreateBorderLayer()
65 : {
66 0 : NS_ASSERTION(InConstruction(), "Only allowed in construction phase");
67 : RefPtr<ClientBorderLayer> layer =
68 0 : new ClientBorderLayer(this);
69 0 : CREATE_SHADOW(Border);
70 0 : return layer.forget();
71 : }
72 :
73 : } // namespace layers
74 : } // namespace mozilla
|