gfx/layers/client/ClientCanvasLayer.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/layers/client/ClientCanvasLayer.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,106 @@
     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 +#ifndef GFX_CLIENTCANVASLAYER_H
    1.10 +#define GFX_CLIENTCANVASLAYER_H
    1.11 +
    1.12 +#include "mozilla/layers/CanvasClient.h"  // for CanvasClient, etc
    1.13 +#include "ClientLayerManager.h"         // for ClientLayerManager, etc
    1.14 +#include "CopyableCanvasLayer.h"        // for CopyableCanvasLayer
    1.15 +#include "Layers.h"                     // for CanvasLayer, etc
    1.16 +#include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
    1.17 +#include "mozilla/RefPtr.h"             // for RefPtr
    1.18 +#include "mozilla/layers/LayersMessages.h"  // for CanvasLayerAttributes, etc
    1.19 +#include "mozilla/mozalloc.h"           // for operator delete
    1.20 +#include "nsAutoPtr.h"                  // for nsRefPtr
    1.21 +#include "nsDebug.h"                    // for NS_ASSERTION
    1.22 +#include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
    1.23 +#include "nsRegion.h"                   // for nsIntRegion
    1.24 +
    1.25 +namespace mozilla {
    1.26 +namespace layers {
    1.27 +
    1.28 +class CompositableClient;
    1.29 +class ShadowableLayer;
    1.30 +
    1.31 +class ClientCanvasLayer : public CopyableCanvasLayer,
    1.32 +                          public ClientLayer
    1.33 +{
    1.34 +  typedef CanvasClient::CanvasClientType CanvasClientType;
    1.35 +public:
    1.36 +  ClientCanvasLayer(ClientLayerManager* aLayerManager) :
    1.37 +    CopyableCanvasLayer(aLayerManager,
    1.38 +                        static_cast<ClientLayer*>(MOZ_THIS_IN_INITIALIZER_LIST()))
    1.39 +    , mTextureSurface(nullptr)
    1.40 +    , mFactory(nullptr)
    1.41 +  {
    1.42 +    MOZ_COUNT_CTOR(ClientCanvasLayer);
    1.43 +  }
    1.44 +  virtual ~ClientCanvasLayer();
    1.45 +
    1.46 +  virtual void SetVisibleRegion(const nsIntRegion& aRegion)
    1.47 +  {
    1.48 +    NS_ASSERTION(ClientManager()->InConstruction(),
    1.49 +                 "Can only set properties in construction phase");
    1.50 +    CanvasLayer::SetVisibleRegion(aRegion);
    1.51 +  }
    1.52 +
    1.53 +  virtual void Initialize(const Data& aData);
    1.54 +
    1.55 +  virtual void RenderLayer();
    1.56 +
    1.57 +  virtual void ClearCachedResources()
    1.58 +  {
    1.59 +    if (mCanvasClient) {
    1.60 +      mCanvasClient->Clear();
    1.61 +    }
    1.62 +  }
    1.63 +
    1.64 +  virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
    1.65 +  {
    1.66 +    aAttrs = CanvasLayerAttributes(mFilter, mBounds);
    1.67 +  }
    1.68 +
    1.69 +  virtual Layer* AsLayer() { return this; }
    1.70 +  virtual ShadowableLayer* AsShadowableLayer() { return this; }
    1.71 +
    1.72 +  virtual void Disconnect()
    1.73 +  {
    1.74 +    mCanvasClient = nullptr;
    1.75 +    ClientLayer::Disconnect();
    1.76 +  }
    1.77 +
    1.78 +  virtual CompositableClient* GetCompositableClient() MOZ_OVERRIDE
    1.79 +  {
    1.80 +    return mCanvasClient;
    1.81 +  }
    1.82 +protected:
    1.83 +  ClientLayerManager* ClientManager()
    1.84 +  {
    1.85 +    return static_cast<ClientLayerManager*>(mManager);
    1.86 +  }
    1.87 +
    1.88 +  CanvasClientType GetCanvasClientType()
    1.89 +  {
    1.90 +    if (mGLContext) {
    1.91 +      return CanvasClient::CanvasClientGLContext;
    1.92 +    }
    1.93 +    return CanvasClient::CanvasClientSurface;
    1.94 +  }
    1.95 +
    1.96 +  RefPtr<CanvasClient> mCanvasClient;
    1.97 +
    1.98 +  gfx::SharedSurface* mTextureSurface;
    1.99 +  gfx::SurfaceFactory* mFactory;
   1.100 +
   1.101 +  friend class DeprecatedCanvasClient2D;
   1.102 +  friend class CanvasClient2D;
   1.103 +  friend class DeprecatedCanvasClientSurfaceStream;
   1.104 +  friend class CanvasClientSurfaceStream;
   1.105 +};
   1.106 +}
   1.107 +}
   1.108 +
   1.109 +#endif

mercurial