gfx/layers/client/ClientColorLayer.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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 #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
    16 using namespace mozilla::gfx;
    18 namespace mozilla {
    19 namespace layers {
    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   }
    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   }
    42   virtual void RenderLayer()
    43   {
    44     if (GetMaskLayer()) {
    45       ToClientLayer(GetMaskLayer())->RenderLayer();
    46     }
    47   }
    49   virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
    50   {
    51     aAttrs = ColorLayerAttributes(GetColor(), GetBounds());
    52   }
    54   virtual Layer* AsLayer() { return this; }
    55   virtual ShadowableLayer* AsShadowableLayer() { return this; }
    57   virtual void Disconnect()
    58   {
    59     ClientLayer::Disconnect();
    60   }
    62 protected:
    63   ClientLayerManager* ClientManager()
    64   {
    65     return static_cast<ClientLayerManager*>(mManager);
    66   }
    67 };
    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 }
    79 }
    80 }

mercurial