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.
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_IMAGECLIENT_H
7 #define MOZILLA_GFX_IMAGECLIENT_H
9 #include <stdint.h> // for uint32_t, uint64_t
10 #include <sys/types.h> // for int32_t
11 #include "mozilla/Attributes.h" // for MOZ_OVERRIDE
12 #include "mozilla/RefPtr.h" // for RefPtr, TemporaryRef
13 #include "mozilla/gfx/Types.h" // for SurfaceFormat
14 #include "mozilla/layers/CompositableClient.h" // for CompositableClient
15 #include "mozilla/layers/CompositorTypes.h" // for CompositableType, etc
16 #include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
17 #include "mozilla/layers/TextureClient.h" // for TextureClient, etc
18 #include "mozilla/mozalloc.h" // for operator delete
19 #include "nsCOMPtr.h" // for already_AddRefed
20 #include "nsRect.h" // for nsIntRect
22 namespace mozilla {
23 namespace layers {
25 class CompositableForwarder;
26 class Image;
27 class ImageContainer;
28 class ShadowableLayer;
30 /**
31 * Image clients are used by basic image layers on the content thread, they
32 * always match with an ImageHost on the compositor thread. See
33 * CompositableClient.h for information on connecting clients to hosts.
34 */
35 class ImageClient : public CompositableClient
36 {
37 public:
38 /**
39 * Creates, configures, and returns a new image client. If necessary, a
40 * message will be sent to the compositor to create a corresponding image
41 * host.
42 */
43 static TemporaryRef<ImageClient> CreateImageClient(CompositableType aImageHostType,
44 CompositableForwarder* aFwd,
45 TextureFlags aFlags);
47 virtual ~ImageClient() {}
49 /**
50 * Update this ImageClient from aContainer in aLayer
51 * returns false if this is the wrong kind of ImageClient for aContainer.
52 * Note that returning true does not necessarily imply success
53 */
54 virtual bool UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags) = 0;
56 /**
57 * The picture rect is the area of the texture which makes up the image. That
58 * is, the area that should be composited. In texture space.
59 */
60 virtual void UpdatePictureRect(nsIntRect aPictureRect);
62 virtual already_AddRefed<Image> CreateImage(ImageFormat aFormat) = 0;
64 /**
65 * Synchronously remove all the textures used by the image client.
66 */
67 virtual void FlushAllImages(bool aExceptFront) {}
69 protected:
70 ImageClient(CompositableForwarder* aFwd, TextureFlags aFlags,
71 CompositableType aType);
73 CompositableType mType;
74 int32_t mLastPaintedImageSerial;
75 nsIntRect mPictureRect;
76 };
78 /**
79 * An image client which uses a single texture client.
80 */
81 class ImageClientSingle : public ImageClient
82 {
83 public:
84 ImageClientSingle(CompositableForwarder* aFwd,
85 TextureFlags aFlags,
86 CompositableType aType);
88 virtual bool UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags);
90 virtual void OnDetach() MOZ_OVERRIDE;
92 virtual bool AddTextureClient(TextureClient* aTexture) MOZ_OVERRIDE;
94 virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE;
96 virtual already_AddRefed<Image> CreateImage(ImageFormat aFormat) MOZ_OVERRIDE;
98 virtual void FlushAllImages(bool aExceptFront) MOZ_OVERRIDE;
100 protected:
101 virtual bool UpdateImageInternal(ImageContainer* aContainer, uint32_t aContentFlags, bool* aIsSwapped);
103 protected:
104 RefPtr<TextureClient> mFrontBuffer;
105 };
107 /**
108 * An image client which uses two texture clients.
109 */
110 class ImageClientBuffered : public ImageClientSingle
111 {
112 public:
113 ImageClientBuffered(CompositableForwarder* aFwd,
114 TextureFlags aFlags,
115 CompositableType aType);
117 virtual bool UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags);
119 virtual void OnDetach() MOZ_OVERRIDE;
121 virtual void FlushAllImages(bool aExceptFront) MOZ_OVERRIDE;
123 protected:
124 RefPtr<TextureClient> mBackBuffer;
125 };
127 /**
128 * Image class to be used for async image uploads using the image bridge
129 * protocol.
130 * We store the ImageBridge id in the TextureClientIdentifier.
131 */
132 class ImageClientBridge : public ImageClient
133 {
134 public:
135 ImageClientBridge(CompositableForwarder* aFwd,
136 TextureFlags aFlags);
138 virtual bool UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags);
139 virtual bool Connect() { return false; }
140 virtual void Updated() {}
141 void SetLayer(ShadowableLayer* aLayer)
142 {
143 mLayer = aLayer;
144 }
146 virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE
147 {
148 return TextureInfo(mType);
149 }
151 virtual void SetIPDLActor(CompositableChild* aChild) MOZ_OVERRIDE
152 {
153 MOZ_ASSERT(!aChild, "ImageClientBridge should not have IPDL actor");
154 }
156 virtual already_AddRefed<Image> CreateImage(ImageFormat aFormat) MOZ_OVERRIDE
157 {
158 NS_WARNING("Should not create an image through an ImageClientBridge");
159 return nullptr;
160 }
162 protected:
163 uint64_t mAsyncContainerID;
164 ShadowableLayer* mLayer;
165 };
167 }
168 }
170 #endif