1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/layers/client/ClientColorLayer.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,80 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "ClientLayerManager.h" // for ClientLayerManager, etc 1.10 +#include "Layers.h" // for ColorLayer, etc 1.11 +#include "mozilla/layers/LayersMessages.h" // for ColorLayerAttributes, etc 1.12 +#include "mozilla/mozalloc.h" // for operator new 1.13 +#include "nsAutoPtr.h" // for nsRefPtr 1.14 +#include "nsCOMPtr.h" // for already_AddRefed 1.15 +#include "nsDebug.h" // for NS_ASSERTION 1.16 +#include "nsISupportsImpl.h" // for Layer::AddRef, etc 1.17 +#include "nsRegion.h" // for nsIntRegion 1.18 + 1.19 +using namespace mozilla::gfx; 1.20 + 1.21 +namespace mozilla { 1.22 +namespace layers { 1.23 + 1.24 +class ClientColorLayer : public ColorLayer, 1.25 + public ClientLayer { 1.26 +public: 1.27 + ClientColorLayer(ClientLayerManager* aLayerManager) : 1.28 + ColorLayer(aLayerManager, 1.29 + static_cast<ClientLayer*>(MOZ_THIS_IN_INITIALIZER_LIST())) 1.30 + { 1.31 + MOZ_COUNT_CTOR(ClientColorLayer); 1.32 + } 1.33 + virtual ~ClientColorLayer() 1.34 + { 1.35 + MOZ_COUNT_DTOR(ClientColorLayer); 1.36 + } 1.37 + 1.38 + virtual void SetVisibleRegion(const nsIntRegion& aRegion) 1.39 + { 1.40 + NS_ASSERTION(ClientManager()->InConstruction(), 1.41 + "Can only set properties in construction phase"); 1.42 + ColorLayer::SetVisibleRegion(aRegion); 1.43 + } 1.44 + 1.45 + virtual void RenderLayer() 1.46 + { 1.47 + if (GetMaskLayer()) { 1.48 + ToClientLayer(GetMaskLayer())->RenderLayer(); 1.49 + } 1.50 + } 1.51 + 1.52 + virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs) 1.53 + { 1.54 + aAttrs = ColorLayerAttributes(GetColor(), GetBounds()); 1.55 + } 1.56 + 1.57 + virtual Layer* AsLayer() { return this; } 1.58 + virtual ShadowableLayer* AsShadowableLayer() { return this; } 1.59 + 1.60 + virtual void Disconnect() 1.61 + { 1.62 + ClientLayer::Disconnect(); 1.63 + } 1.64 + 1.65 +protected: 1.66 + ClientLayerManager* ClientManager() 1.67 + { 1.68 + return static_cast<ClientLayerManager*>(mManager); 1.69 + } 1.70 +}; 1.71 + 1.72 +already_AddRefed<ColorLayer> 1.73 +ClientLayerManager::CreateColorLayer() 1.74 +{ 1.75 + NS_ASSERTION(InConstruction(), "Only allowed in construction phase"); 1.76 + nsRefPtr<ClientColorLayer> layer = 1.77 + new ClientColorLayer(this); 1.78 + CREATE_SHADOW(Color); 1.79 + return layer.forget(); 1.80 +} 1.81 + 1.82 +} 1.83 +}