gfx/layers/client/ClientColorLayer.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 2 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "ClientLayerManager.h" // for ClientLayerManager, etc
michael@0 7 #include "Layers.h" // for ColorLayer, etc
michael@0 8 #include "mozilla/layers/LayersMessages.h" // for ColorLayerAttributes, etc
michael@0 9 #include "mozilla/mozalloc.h" // for operator new
michael@0 10 #include "nsAutoPtr.h" // for nsRefPtr
michael@0 11 #include "nsCOMPtr.h" // for already_AddRefed
michael@0 12 #include "nsDebug.h" // for NS_ASSERTION
michael@0 13 #include "nsISupportsImpl.h" // for Layer::AddRef, etc
michael@0 14 #include "nsRegion.h" // for nsIntRegion
michael@0 15
michael@0 16 using namespace mozilla::gfx;
michael@0 17
michael@0 18 namespace mozilla {
michael@0 19 namespace layers {
michael@0 20
michael@0 21 class ClientColorLayer : public ColorLayer,
michael@0 22 public ClientLayer {
michael@0 23 public:
michael@0 24 ClientColorLayer(ClientLayerManager* aLayerManager) :
michael@0 25 ColorLayer(aLayerManager,
michael@0 26 static_cast<ClientLayer*>(MOZ_THIS_IN_INITIALIZER_LIST()))
michael@0 27 {
michael@0 28 MOZ_COUNT_CTOR(ClientColorLayer);
michael@0 29 }
michael@0 30 virtual ~ClientColorLayer()
michael@0 31 {
michael@0 32 MOZ_COUNT_DTOR(ClientColorLayer);
michael@0 33 }
michael@0 34
michael@0 35 virtual void SetVisibleRegion(const nsIntRegion& aRegion)
michael@0 36 {
michael@0 37 NS_ASSERTION(ClientManager()->InConstruction(),
michael@0 38 "Can only set properties in construction phase");
michael@0 39 ColorLayer::SetVisibleRegion(aRegion);
michael@0 40 }
michael@0 41
michael@0 42 virtual void RenderLayer()
michael@0 43 {
michael@0 44 if (GetMaskLayer()) {
michael@0 45 ToClientLayer(GetMaskLayer())->RenderLayer();
michael@0 46 }
michael@0 47 }
michael@0 48
michael@0 49 virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
michael@0 50 {
michael@0 51 aAttrs = ColorLayerAttributes(GetColor(), GetBounds());
michael@0 52 }
michael@0 53
michael@0 54 virtual Layer* AsLayer() { return this; }
michael@0 55 virtual ShadowableLayer* AsShadowableLayer() { return this; }
michael@0 56
michael@0 57 virtual void Disconnect()
michael@0 58 {
michael@0 59 ClientLayer::Disconnect();
michael@0 60 }
michael@0 61
michael@0 62 protected:
michael@0 63 ClientLayerManager* ClientManager()
michael@0 64 {
michael@0 65 return static_cast<ClientLayerManager*>(mManager);
michael@0 66 }
michael@0 67 };
michael@0 68
michael@0 69 already_AddRefed<ColorLayer>
michael@0 70 ClientLayerManager::CreateColorLayer()
michael@0 71 {
michael@0 72 NS_ASSERTION(InConstruction(), "Only allowed in construction phase");
michael@0 73 nsRefPtr<ClientColorLayer> layer =
michael@0 74 new ClientColorLayer(this);
michael@0 75 CREATE_SHADOW(Color);
michael@0 76 return layer.forget();
michael@0 77 }
michael@0 78
michael@0 79 }
michael@0 80 }

mercurial