Sat, 03 Jan 2015 20:18:00 +0100
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.
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 | #ifndef GFX_CLIENTLAYERMANAGER_H |
michael@0 | 7 | #define GFX_CLIENTLAYERMANAGER_H |
michael@0 | 8 | |
michael@0 | 9 | #include <stdint.h> // for int32_t |
michael@0 | 10 | #include "Layers.h" |
michael@0 | 11 | #include "gfxContext.h" // for gfxContext |
michael@0 | 12 | #include "mozilla/Attributes.h" // for MOZ_OVERRIDE |
michael@0 | 13 | #include "mozilla/LinkedList.h" // For LinkedList |
michael@0 | 14 | #include "mozilla/WidgetUtils.h" // for ScreenRotation |
michael@0 | 15 | #include "mozilla/gfx/Rect.h" // for Rect |
michael@0 | 16 | #include "mozilla/layers/CompositorTypes.h" |
michael@0 | 17 | #include "mozilla/layers/LayersTypes.h" // for BufferMode, LayersBackend, etc |
michael@0 | 18 | #include "mozilla/layers/ShadowLayers.h" // for ShadowLayerForwarder, etc |
michael@0 | 19 | #include "nsAutoPtr.h" // for nsRefPtr |
michael@0 | 20 | #include "nsCOMPtr.h" // for already_AddRefed |
michael@0 | 21 | #include "nsDebug.h" // for NS_ABORT_IF_FALSE |
michael@0 | 22 | #include "nsISupportsImpl.h" // for Layer::Release, etc |
michael@0 | 23 | #include "nsRect.h" // for nsIntRect |
michael@0 | 24 | #include "nsTArray.h" // for nsTArray |
michael@0 | 25 | #include "nscore.h" // for nsAString |
michael@0 | 26 | |
michael@0 | 27 | class nsIWidget; |
michael@0 | 28 | |
michael@0 | 29 | namespace mozilla { |
michael@0 | 30 | namespace layers { |
michael@0 | 31 | |
michael@0 | 32 | class ClientThebesLayer; |
michael@0 | 33 | class CompositorChild; |
michael@0 | 34 | class ImageLayer; |
michael@0 | 35 | class PLayerChild; |
michael@0 | 36 | class TextureClientPool; |
michael@0 | 37 | class SimpleTextureClientPool; |
michael@0 | 38 | |
michael@0 | 39 | class ClientLayerManager : public LayerManager |
michael@0 | 40 | { |
michael@0 | 41 | typedef nsTArray<nsRefPtr<Layer> > LayerRefArray; |
michael@0 | 42 | |
michael@0 | 43 | public: |
michael@0 | 44 | ClientLayerManager(nsIWidget* aWidget); |
michael@0 | 45 | virtual ~ClientLayerManager(); |
michael@0 | 46 | |
michael@0 | 47 | virtual ShadowLayerForwarder* AsShadowForwarder() |
michael@0 | 48 | { |
michael@0 | 49 | return mForwarder; |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | virtual int32_t GetMaxTextureSize() const; |
michael@0 | 53 | |
michael@0 | 54 | virtual void SetDefaultTargetConfiguration(BufferMode aDoubleBuffering, ScreenRotation aRotation); |
michael@0 | 55 | virtual void BeginTransactionWithTarget(gfxContext* aTarget); |
michael@0 | 56 | virtual void BeginTransaction(); |
michael@0 | 57 | virtual bool EndEmptyTransaction(EndTransactionFlags aFlags = END_DEFAULT); |
michael@0 | 58 | virtual void EndTransaction(DrawThebesLayerCallback aCallback, |
michael@0 | 59 | void* aCallbackData, |
michael@0 | 60 | EndTransactionFlags aFlags = END_DEFAULT); |
michael@0 | 61 | |
michael@0 | 62 | virtual LayersBackend GetBackendType() { return LayersBackend::LAYERS_CLIENT; } |
michael@0 | 63 | virtual LayersBackend GetCompositorBackendType() MOZ_OVERRIDE |
michael@0 | 64 | { |
michael@0 | 65 | return AsShadowForwarder()->GetCompositorBackendType(); |
michael@0 | 66 | } |
michael@0 | 67 | virtual void GetBackendName(nsAString& name); |
michael@0 | 68 | virtual const char* Name() const { return "Client"; } |
michael@0 | 69 | |
michael@0 | 70 | virtual void SetRoot(Layer* aLayer); |
michael@0 | 71 | |
michael@0 | 72 | virtual void Mutated(Layer* aLayer); |
michael@0 | 73 | |
michael@0 | 74 | virtual already_AddRefed<ThebesLayer> CreateThebesLayer(); |
michael@0 | 75 | virtual already_AddRefed<ThebesLayer> CreateThebesLayerWithHint(ThebesLayerCreationHint aHint); |
michael@0 | 76 | virtual already_AddRefed<ContainerLayer> CreateContainerLayer(); |
michael@0 | 77 | virtual already_AddRefed<ImageLayer> CreateImageLayer(); |
michael@0 | 78 | virtual already_AddRefed<CanvasLayer> CreateCanvasLayer(); |
michael@0 | 79 | virtual already_AddRefed<ColorLayer> CreateColorLayer(); |
michael@0 | 80 | virtual already_AddRefed<RefLayer> CreateRefLayer(); |
michael@0 | 81 | |
michael@0 | 82 | TextureFactoryIdentifier GetTextureFactoryIdentifier() |
michael@0 | 83 | { |
michael@0 | 84 | return mForwarder->GetTextureFactoryIdentifier(); |
michael@0 | 85 | } |
michael@0 | 86 | |
michael@0 | 87 | virtual void FlushRendering() MOZ_OVERRIDE; |
michael@0 | 88 | void SendInvalidRegion(const nsIntRegion& aRegion); |
michael@0 | 89 | |
michael@0 | 90 | virtual uint32_t StartFrameTimeRecording(int32_t aBufferSize) MOZ_OVERRIDE; |
michael@0 | 91 | |
michael@0 | 92 | virtual void StopFrameTimeRecording(uint32_t aStartIndex, |
michael@0 | 93 | nsTArray<float>& aFrameIntervals) MOZ_OVERRIDE; |
michael@0 | 94 | |
michael@0 | 95 | virtual bool NeedsWidgetInvalidation() MOZ_OVERRIDE { return false; } |
michael@0 | 96 | |
michael@0 | 97 | ShadowableLayer* Hold(Layer* aLayer); |
michael@0 | 98 | |
michael@0 | 99 | bool HasShadowManager() const { return mForwarder->HasShadowManager(); } |
michael@0 | 100 | |
michael@0 | 101 | virtual bool IsCompositingCheap(); |
michael@0 | 102 | virtual bool HasShadowManagerInternal() const { return HasShadowManager(); } |
michael@0 | 103 | |
michael@0 | 104 | virtual void SetIsFirstPaint() MOZ_OVERRIDE; |
michael@0 | 105 | |
michael@0 | 106 | TextureClientPool *GetTexturePool(gfx::SurfaceFormat aFormat); |
michael@0 | 107 | SimpleTextureClientPool *GetSimpleTileTexturePool(gfx::SurfaceFormat aFormat); |
michael@0 | 108 | |
michael@0 | 109 | // Drop cached resources and ask our shadow manager to do the same, |
michael@0 | 110 | // if we have one. |
michael@0 | 111 | virtual void ClearCachedResources(Layer* aSubtree = nullptr) MOZ_OVERRIDE; |
michael@0 | 112 | |
michael@0 | 113 | void SetRepeatTransaction() { mRepeatTransaction = true; } |
michael@0 | 114 | bool GetRepeatTransaction() { return mRepeatTransaction; } |
michael@0 | 115 | |
michael@0 | 116 | bool IsRepeatTransaction() { return mIsRepeatTransaction; } |
michael@0 | 117 | |
michael@0 | 118 | void SetTransactionIncomplete() { mTransactionIncomplete = true; } |
michael@0 | 119 | |
michael@0 | 120 | bool HasShadowTarget() { return !!mShadowTarget; } |
michael@0 | 121 | |
michael@0 | 122 | void SetShadowTarget(gfxContext *aTarget) { mShadowTarget = aTarget; } |
michael@0 | 123 | |
michael@0 | 124 | bool CompositorMightResample() { return mCompositorMightResample; } |
michael@0 | 125 | |
michael@0 | 126 | DrawThebesLayerCallback GetThebesLayerCallback() const |
michael@0 | 127 | { return mThebesLayerCallback; } |
michael@0 | 128 | |
michael@0 | 129 | void* GetThebesLayerCallbackData() const |
michael@0 | 130 | { return mThebesLayerCallbackData; } |
michael@0 | 131 | |
michael@0 | 132 | CompositorChild *GetRemoteRenderer(); |
michael@0 | 133 | |
michael@0 | 134 | /** |
michael@0 | 135 | * Called for each iteration of a progressive tile update. Fills |
michael@0 | 136 | * aCompositionBounds and aZoom with the current scale and composition bounds |
michael@0 | 137 | * being used to composite the layers in this manager, to determine what area |
michael@0 | 138 | * intersects with the target composition bounds. |
michael@0 | 139 | * aDrawingCritical will be true if the current drawing operation is using |
michael@0 | 140 | * the critical displayport. |
michael@0 | 141 | * Returns true if the update should continue, or false if it should be |
michael@0 | 142 | * cancelled. |
michael@0 | 143 | * This is only called if gfxPlatform::UseProgressiveTilePainting() returns |
michael@0 | 144 | * true. |
michael@0 | 145 | */ |
michael@0 | 146 | bool ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, |
michael@0 | 147 | ParentLayerRect& aCompositionBounds, |
michael@0 | 148 | CSSToParentLayerScale& aZoom, |
michael@0 | 149 | bool aDrawingCritical); |
michael@0 | 150 | |
michael@0 | 151 | bool InConstruction() { return mPhase == PHASE_CONSTRUCTION; } |
michael@0 | 152 | #ifdef DEBUG |
michael@0 | 153 | bool InDrawing() { return mPhase == PHASE_DRAWING; } |
michael@0 | 154 | bool InForward() { return mPhase == PHASE_FORWARD; } |
michael@0 | 155 | #endif |
michael@0 | 156 | bool InTransaction() { return mPhase != PHASE_NONE; } |
michael@0 | 157 | |
michael@0 | 158 | void SetNeedsComposite(bool aNeedsComposite) |
michael@0 | 159 | { |
michael@0 | 160 | mNeedsComposite = aNeedsComposite; |
michael@0 | 161 | } |
michael@0 | 162 | bool NeedsComposite() const { return mNeedsComposite; } |
michael@0 | 163 | |
michael@0 | 164 | virtual void Composite() MOZ_OVERRIDE; |
michael@0 | 165 | |
michael@0 | 166 | virtual void DidComposite(); |
michael@0 | 167 | |
michael@0 | 168 | protected: |
michael@0 | 169 | enum TransactionPhase { |
michael@0 | 170 | PHASE_NONE, PHASE_CONSTRUCTION, PHASE_DRAWING, PHASE_FORWARD |
michael@0 | 171 | }; |
michael@0 | 172 | TransactionPhase mPhase; |
michael@0 | 173 | |
michael@0 | 174 | private: |
michael@0 | 175 | /** |
michael@0 | 176 | * Forward transaction results to the parent context. |
michael@0 | 177 | */ |
michael@0 | 178 | void ForwardTransaction(bool aScheduleComposite); |
michael@0 | 179 | |
michael@0 | 180 | /** |
michael@0 | 181 | * Take a snapshot of the parent context, and copy |
michael@0 | 182 | * it into mShadowTarget. |
michael@0 | 183 | */ |
michael@0 | 184 | void MakeSnapshotIfRequired(); |
michael@0 | 185 | |
michael@0 | 186 | void ClearLayer(Layer* aLayer); |
michael@0 | 187 | |
michael@0 | 188 | bool EndTransactionInternal(DrawThebesLayerCallback aCallback, |
michael@0 | 189 | void* aCallbackData, |
michael@0 | 190 | EndTransactionFlags); |
michael@0 | 191 | |
michael@0 | 192 | // The bounds of |mTarget| in device pixels. |
michael@0 | 193 | nsIntRect mTargetBounds; |
michael@0 | 194 | |
michael@0 | 195 | LayerRefArray mKeepAlive; |
michael@0 | 196 | |
michael@0 | 197 | nsIWidget* mWidget; |
michael@0 | 198 | |
michael@0 | 199 | /* Thebes layer callbacks; valid at the end of a transaciton, |
michael@0 | 200 | * while rendering */ |
michael@0 | 201 | DrawThebesLayerCallback mThebesLayerCallback; |
michael@0 | 202 | void *mThebesLayerCallbackData; |
michael@0 | 203 | |
michael@0 | 204 | // When we're doing a transaction in order to draw to a non-default |
michael@0 | 205 | // target, the layers transaction is only performed in order to send |
michael@0 | 206 | // a PLayers:Update. We save the original non-default target to |
michael@0 | 207 | // mShadowTarget, and then perform the transaction using |
michael@0 | 208 | // mDummyTarget as the render target. After the transaction ends, |
michael@0 | 209 | // we send a message to our remote side to capture the actual pixels |
michael@0 | 210 | // being drawn to the default target, and then copy those pixels |
michael@0 | 211 | // back to mShadowTarget. |
michael@0 | 212 | nsRefPtr<gfxContext> mShadowTarget; |
michael@0 | 213 | |
michael@0 | 214 | // Sometimes we draw to targets that don't natively support |
michael@0 | 215 | // landscape/portrait orientation. When we need to implement that |
michael@0 | 216 | // ourselves, |mTargetRotation| describes the induced transform we |
michael@0 | 217 | // need to apply when compositing content to our target. |
michael@0 | 218 | ScreenRotation mTargetRotation; |
michael@0 | 219 | |
michael@0 | 220 | // Used to repeat the transaction right away (to avoid rebuilding |
michael@0 | 221 | // a display list) to support progressive drawing. |
michael@0 | 222 | bool mRepeatTransaction; |
michael@0 | 223 | bool mIsRepeatTransaction; |
michael@0 | 224 | bool mTransactionIncomplete; |
michael@0 | 225 | bool mCompositorMightResample; |
michael@0 | 226 | bool mNeedsComposite; |
michael@0 | 227 | |
michael@0 | 228 | RefPtr<ShadowLayerForwarder> mForwarder; |
michael@0 | 229 | nsAutoTArray<RefPtr<TextureClientPool>,2> mTexturePools; |
michael@0 | 230 | |
michael@0 | 231 | // indexed by gfx::SurfaceFormat |
michael@0 | 232 | nsTArray<RefPtr<SimpleTextureClientPool> > mSimpleTilePools; |
michael@0 | 233 | }; |
michael@0 | 234 | |
michael@0 | 235 | class ClientLayer : public ShadowableLayer |
michael@0 | 236 | { |
michael@0 | 237 | public: |
michael@0 | 238 | ClientLayer() |
michael@0 | 239 | { |
michael@0 | 240 | MOZ_COUNT_CTOR(ClientLayer); |
michael@0 | 241 | } |
michael@0 | 242 | |
michael@0 | 243 | ~ClientLayer(); |
michael@0 | 244 | |
michael@0 | 245 | void SetShadow(PLayerChild* aShadow) |
michael@0 | 246 | { |
michael@0 | 247 | NS_ABORT_IF_FALSE(!mShadow, "can't have two shadows (yet)"); |
michael@0 | 248 | mShadow = aShadow; |
michael@0 | 249 | } |
michael@0 | 250 | |
michael@0 | 251 | virtual void Disconnect() |
michael@0 | 252 | { |
michael@0 | 253 | // This is an "emergency Disconnect()", called when the compositing |
michael@0 | 254 | // process has died. |mShadow| and our Shmem buffers are |
michael@0 | 255 | // automatically managed by IPDL, so we don't need to explicitly |
michael@0 | 256 | // free them here (it's hard to get that right on emergency |
michael@0 | 257 | // shutdown anyway). |
michael@0 | 258 | mShadow = nullptr; |
michael@0 | 259 | } |
michael@0 | 260 | |
michael@0 | 261 | virtual void ClearCachedResources() { } |
michael@0 | 262 | |
michael@0 | 263 | virtual void RenderLayer() = 0; |
michael@0 | 264 | |
michael@0 | 265 | virtual ClientThebesLayer* AsThebes() { return nullptr; } |
michael@0 | 266 | |
michael@0 | 267 | static inline ClientLayer * |
michael@0 | 268 | ToClientLayer(Layer* aLayer) |
michael@0 | 269 | { |
michael@0 | 270 | return static_cast<ClientLayer*>(aLayer->ImplData()); |
michael@0 | 271 | } |
michael@0 | 272 | }; |
michael@0 | 273 | |
michael@0 | 274 | // Create a shadow layer (PLayerChild) for aLayer, if we're forwarding |
michael@0 | 275 | // our layer tree to a parent process. Record the new layer creation |
michael@0 | 276 | // in the current open transaction as a side effect. |
michael@0 | 277 | template<typename CreatedMethod> void |
michael@0 | 278 | CreateShadowFor(ClientLayer* aLayer, |
michael@0 | 279 | ClientLayerManager* aMgr, |
michael@0 | 280 | CreatedMethod aMethod) |
michael@0 | 281 | { |
michael@0 | 282 | PLayerChild* shadow = aMgr->AsShadowForwarder()->ConstructShadowFor(aLayer); |
michael@0 | 283 | // XXX error handling |
michael@0 | 284 | NS_ABORT_IF_FALSE(shadow, "failed to create shadow"); |
michael@0 | 285 | |
michael@0 | 286 | aLayer->SetShadow(shadow); |
michael@0 | 287 | (aMgr->AsShadowForwarder()->*aMethod)(aLayer); |
michael@0 | 288 | aMgr->Hold(aLayer->AsLayer()); |
michael@0 | 289 | } |
michael@0 | 290 | |
michael@0 | 291 | #define CREATE_SHADOW(_type) \ |
michael@0 | 292 | CreateShadowFor(layer, this, \ |
michael@0 | 293 | &ShadowLayerForwarder::Created ## _type ## Layer) |
michael@0 | 294 | |
michael@0 | 295 | |
michael@0 | 296 | } |
michael@0 | 297 | } |
michael@0 | 298 | |
michael@0 | 299 | #endif /* GFX_CLIENTLAYERMANAGER_H */ |