gfx/layers/client/SimpleTiledContentClient.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* -*- Mode: C++; tab-width: 20; 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 #ifndef MOZILLA_GFX_SIMPLETILEDCONTENTCLIENT_H
     7 #define MOZILLA_GFX_SIMPLETILEDCONTENTCLIENT_H
     9 // We include this header here so that we don't need to
    10 // duplicate BasicTiledLayerPaintData
    11 #include "TiledContentClient.h"
    13 #include "SharedBuffer.h"
    15 namespace mozilla {
    16 namespace layers {
    18 class ClientTiledThebesLayer;
    20 class SimpleTiledLayerTile;
    21 class SimpleTiledLayerBuffer;
    22 class SimpleClientTiledThebesLayer;
    23 class SimpleTiledLayerBuffer;
    25 #define GFX_SIMP_TILEDLAYER_DEBUG_OVERLAY
    27 struct SimpleTiledLayerTile
    28 {
    29   RefPtr<TextureClient> mTileBuffer;
    30   RefPtr<ClientLayerManager> mManager;
    31   nsRefPtr<SharedBuffer> mCachedBuffer;
    32   TimeStamp mLastUpdate;
    34   SimpleTiledLayerTile() { }
    36   SimpleTiledLayerTile(ClientLayerManager *aManager, TextureClient *aBuffer)
    37     : mTileBuffer(aBuffer)
    38     , mManager(aManager)
    39   { }
    41   bool operator== (const SimpleTiledLayerTile& o) const
    42   {
    43     return mTileBuffer == o.mTileBuffer;
    44   }
    46   bool operator!= (const SimpleTiledLayerTile& o) const
    47   {
    48     return mTileBuffer != o.mTileBuffer;
    49   }
    51   void SetLayerManager(ClientLayerManager *aManager)
    52   {
    53     mManager = aManager;
    54   }
    56   bool IsPlaceholderTile()
    57   {
    58     return mTileBuffer == nullptr;
    59   }
    61   TileDescriptor GetTileDescriptor()
    62   {
    63     if (mTileBuffer)
    64       return TexturedTileDescriptor(nullptr, mTileBuffer->GetIPDLActor(), 0);
    66     NS_NOTREACHED("Unhandled SimpleTiledLayerTile type");
    67     return PlaceholderTileDescriptor();
    68   }
    70   void Release()
    71   {
    72     mTileBuffer = nullptr;
    73     mCachedBuffer = nullptr;
    74   }
    75 };
    77 class SimpleTiledLayerBuffer
    78   : public TiledLayerBuffer<SimpleTiledLayerBuffer, SimpleTiledLayerTile>
    79 {
    80   friend class TiledLayerBuffer<SimpleTiledLayerBuffer, SimpleTiledLayerTile>;
    82 public:
    83   SimpleTiledLayerBuffer(SimpleClientTiledThebesLayer* aThebesLayer,
    84                          CompositableClient* aCompositableClient,
    85                          ClientLayerManager* aManager)
    86     : mThebesLayer(aThebesLayer)
    87     , mCompositableClient(aCompositableClient)
    88     , mManager(aManager)
    89     , mLastPaintOpaque(false)
    90   {}
    92   SimpleTiledLayerBuffer()
    93     : mLastPaintOpaque(false)
    94   {}
    96   void PaintThebes(const nsIntRegion& aNewValidRegion,
    97                    const nsIntRegion& aPaintRegion,
    98                    LayerManager::DrawThebesLayerCallback aCallback,
    99                    void* aCallbackData);
   101   SurfaceDescriptorTiles GetSurfaceDescriptorTiles();
   103   void Release() {
   104     for (size_t i = 0; i < mRetainedTiles.Length(); i++) {
   105       mRetainedTiles[i].Release();
   106     }
   107   }
   109   const CSSToParentLayerScale& GetFrameResolution() const { return mFrameResolution; }
   110   void SetFrameResolution(const CSSToParentLayerScale& aResolution) { mFrameResolution = aResolution; }
   112   bool HasFormatChanged() const;
   113 private:
   114   SimpleClientTiledThebesLayer* mThebesLayer;
   115   CompositableClient* mCompositableClient;
   116   ClientLayerManager* mManager;
   117   LayerManager::DrawThebesLayerCallback mCallback;
   118   void* mCallbackData;
   119   CSSToParentLayerScale mFrameResolution;
   120   bool mLastPaintOpaque;
   122   gfxContentType GetContentType() const;
   124   SimpleTiledLayerTile ValidateTile(SimpleTiledLayerTile aTile,
   125                                     const nsIntPoint& aTileOrigin,
   126                                     const nsIntRegion& aDirtyRect);
   128   SimpleTiledLayerTile GetPlaceholderTile() const { return SimpleTiledLayerTile(); }
   130   void ReleaseTile(SimpleTiledLayerTile aTile) { aTile.Release(); }
   132   void SwapTiles(SimpleTiledLayerTile& aTileA, SimpleTiledLayerTile& aTileB) { std::swap(aTileA, aTileB); }
   133 };
   135 class SimpleTiledContentClient : public CompositableClient
   136 {
   137   friend class SimpleClientTiledThebesLayer;
   139 public:
   140   SimpleTiledContentClient(SimpleClientTiledThebesLayer* aThebesLayer,
   141                            ClientLayerManager* aManager);
   143   ~SimpleTiledContentClient();
   145   virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE
   146   {
   147     return TextureInfo(BUFFER_SIMPLE_TILED);
   148   }
   150   void UseTiledLayerBuffer();
   152 private:
   153   SimpleTiledLayerBuffer mTiledBuffer;
   154 };
   156 class SimpleClientTiledThebesLayer : public ThebesLayer,
   157                                      public ClientLayer
   158 {
   159   typedef ThebesLayer Base;
   161 public:
   162   SimpleClientTiledThebesLayer(ClientLayerManager* const aManager);
   163   ~SimpleClientTiledThebesLayer();
   165   // Thebes Layer
   166   virtual Layer* AsLayer() { return this; }
   167   virtual void InvalidateRegion(const nsIntRegion& aRegion) {
   168     mInvalidRegion.Or(mInvalidRegion, aRegion);
   169     mValidRegion.Sub(mValidRegion, aRegion);
   170   }
   172   // Shadow methods
   173   virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs);
   174   virtual ShadowableLayer* AsShadowableLayer() { return this; }
   176   virtual void Disconnect() { ClientLayer::Disconnect(); }
   178   virtual void RenderLayer();
   180 protected:
   181   ClientLayerManager* ClientManager() { return static_cast<ClientLayerManager*>(mManager); }
   183   RefPtr<SimpleTiledContentClient> mContentClient;
   184 };
   186 } // mozilla
   187 } // layers
   189 #endif

mercurial