gfx/layers/client/ClientColorLayer.cpp

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:504757ee959d
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 "nsAutoPtr.h" // for nsRefPtr
11 #include "nsCOMPtr.h" // for already_AddRefed
12 #include "nsDebug.h" // for NS_ASSERTION
13 #include "nsISupportsImpl.h" // for Layer::AddRef, etc
14 #include "nsRegion.h" // for nsIntRegion
15
16 using namespace mozilla::gfx;
17
18 namespace mozilla {
19 namespace layers {
20
21 class ClientColorLayer : public ColorLayer,
22 public ClientLayer {
23 public:
24 ClientColorLayer(ClientLayerManager* aLayerManager) :
25 ColorLayer(aLayerManager,
26 static_cast<ClientLayer*>(MOZ_THIS_IN_INITIALIZER_LIST()))
27 {
28 MOZ_COUNT_CTOR(ClientColorLayer);
29 }
30 virtual ~ClientColorLayer()
31 {
32 MOZ_COUNT_DTOR(ClientColorLayer);
33 }
34
35 virtual void SetVisibleRegion(const nsIntRegion& aRegion)
36 {
37 NS_ASSERTION(ClientManager()->InConstruction(),
38 "Can only set properties in construction phase");
39 ColorLayer::SetVisibleRegion(aRegion);
40 }
41
42 virtual void RenderLayer()
43 {
44 if (GetMaskLayer()) {
45 ToClientLayer(GetMaskLayer())->RenderLayer();
46 }
47 }
48
49 virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
50 {
51 aAttrs = ColorLayerAttributes(GetColor(), GetBounds());
52 }
53
54 virtual Layer* AsLayer() { return this; }
55 virtual ShadowableLayer* AsShadowableLayer() { return this; }
56
57 virtual void Disconnect()
58 {
59 ClientLayer::Disconnect();
60 }
61
62 protected:
63 ClientLayerManager* ClientManager()
64 {
65 return static_cast<ClientLayerManager*>(mManager);
66 }
67 };
68
69 already_AddRefed<ColorLayer>
70 ClientLayerManager::CreateColorLayer()
71 {
72 NS_ASSERTION(InConstruction(), "Only allowed in construction phase");
73 nsRefPtr<ClientColorLayer> layer =
74 new ClientColorLayer(this);
75 CREATE_SHADOW(Color);
76 return layer.forget();
77 }
78
79 }
80 }

mercurial