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: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
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 MOZILLA_GFX_TEXTURED3D11_H |
michael@0 | 7 | #define MOZILLA_GFX_TEXTURED3D11_H |
michael@0 | 8 | |
michael@0 | 9 | #include "mozilla/layers/Compositor.h" |
michael@0 | 10 | #include "mozilla/layers/TextureClient.h" |
michael@0 | 11 | #include "mozilla/layers/TextureHost.h" |
michael@0 | 12 | #include "gfxWindowsPlatform.h" |
michael@0 | 13 | #include "mozilla/GfxMessageUtils.h" |
michael@0 | 14 | #include <d3d11.h> |
michael@0 | 15 | #include <vector> |
michael@0 | 16 | |
michael@0 | 17 | class gfxD2DSurface; |
michael@0 | 18 | |
michael@0 | 19 | namespace mozilla { |
michael@0 | 20 | namespace layers { |
michael@0 | 21 | |
michael@0 | 22 | class CompositorD3D11; |
michael@0 | 23 | |
michael@0 | 24 | /** |
michael@0 | 25 | * A TextureClient to share a D3D10 texture with the compositor thread. |
michael@0 | 26 | * The corresponding TextureHost is DXGITextureHostD3D11 |
michael@0 | 27 | */ |
michael@0 | 28 | class TextureClientD3D11 : public TextureClient |
michael@0 | 29 | { |
michael@0 | 30 | public: |
michael@0 | 31 | TextureClientD3D11(gfx::SurfaceFormat aFormat, TextureFlags aFlags); |
michael@0 | 32 | |
michael@0 | 33 | virtual ~TextureClientD3D11(); |
michael@0 | 34 | |
michael@0 | 35 | // TextureClient |
michael@0 | 36 | |
michael@0 | 37 | virtual bool IsAllocated() const MOZ_OVERRIDE { return !!mTexture; } |
michael@0 | 38 | |
michael@0 | 39 | virtual bool Lock(OpenMode aOpenMode) MOZ_OVERRIDE; |
michael@0 | 40 | |
michael@0 | 41 | virtual void Unlock() MOZ_OVERRIDE; |
michael@0 | 42 | |
michael@0 | 43 | virtual bool IsLocked() const MOZ_OVERRIDE { return mIsLocked; } |
michael@0 | 44 | |
michael@0 | 45 | virtual bool ImplementsLocking() const MOZ_OVERRIDE { return true; } |
michael@0 | 46 | |
michael@0 | 47 | virtual bool HasInternalBuffer() const MOZ_OVERRIDE { return false; } |
michael@0 | 48 | |
michael@0 | 49 | virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) MOZ_OVERRIDE; |
michael@0 | 50 | |
michael@0 | 51 | virtual gfx::IntSize GetSize() const MOZ_OVERRIDE { return mSize; } |
michael@0 | 52 | |
michael@0 | 53 | virtual TextureClientData* DropTextureData() MOZ_OVERRIDE { return nullptr; } |
michael@0 | 54 | |
michael@0 | 55 | virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { return mFormat; } |
michael@0 | 56 | |
michael@0 | 57 | virtual bool CanExposeDrawTarget() const MOZ_OVERRIDE { return true; } |
michael@0 | 58 | |
michael@0 | 59 | virtual TemporaryRef<gfx::DrawTarget> GetAsDrawTarget() MOZ_OVERRIDE; |
michael@0 | 60 | |
michael@0 | 61 | virtual bool AllocateForSurface(gfx::IntSize aSize, |
michael@0 | 62 | TextureAllocationFlags aFlags = ALLOC_DEFAULT) MOZ_OVERRIDE; |
michael@0 | 63 | |
michael@0 | 64 | protected: |
michael@0 | 65 | gfx::IntSize mSize; |
michael@0 | 66 | RefPtr<ID3D10Texture2D> mTexture; |
michael@0 | 67 | RefPtr<gfx::DrawTarget> mDrawTarget; |
michael@0 | 68 | gfx::SurfaceFormat mFormat; |
michael@0 | 69 | bool mIsLocked; |
michael@0 | 70 | bool mNeedsClear; |
michael@0 | 71 | }; |
michael@0 | 72 | |
michael@0 | 73 | /** |
michael@0 | 74 | * TextureSource that provides with the necessary APIs to be composited by a |
michael@0 | 75 | * CompositorD3D11. |
michael@0 | 76 | */ |
michael@0 | 77 | class TextureSourceD3D11 |
michael@0 | 78 | { |
michael@0 | 79 | public: |
michael@0 | 80 | TextureSourceD3D11() {} |
michael@0 | 81 | virtual ~TextureSourceD3D11() {} |
michael@0 | 82 | |
michael@0 | 83 | virtual ID3D11Texture2D* GetD3D11Texture() const { return mTexture; } |
michael@0 | 84 | |
michael@0 | 85 | protected: |
michael@0 | 86 | virtual gfx::IntSize GetSize() const { return mSize; } |
michael@0 | 87 | |
michael@0 | 88 | gfx::IntSize mSize; |
michael@0 | 89 | RefPtr<ID3D11Texture2D> mTexture; |
michael@0 | 90 | }; |
michael@0 | 91 | |
michael@0 | 92 | /** |
michael@0 | 93 | * A TextureSource that implements the DataTextureSource interface. |
michael@0 | 94 | * it can be used without a TextureHost and is able to upload texture data |
michael@0 | 95 | * from a gfx::DataSourceSurface. |
michael@0 | 96 | */ |
michael@0 | 97 | class DataTextureSourceD3D11 : public DataTextureSource |
michael@0 | 98 | , public TextureSourceD3D11 |
michael@0 | 99 | , public TileIterator |
michael@0 | 100 | { |
michael@0 | 101 | public: |
michael@0 | 102 | DataTextureSourceD3D11(gfx::SurfaceFormat aFormat, CompositorD3D11* aCompositor, |
michael@0 | 103 | TextureFlags aFlags); |
michael@0 | 104 | |
michael@0 | 105 | DataTextureSourceD3D11(gfx::SurfaceFormat aFormat, CompositorD3D11* aCompositor, |
michael@0 | 106 | ID3D11Texture2D* aTexture); |
michael@0 | 107 | |
michael@0 | 108 | virtual ~DataTextureSourceD3D11(); |
michael@0 | 109 | |
michael@0 | 110 | |
michael@0 | 111 | // DataTextureSource |
michael@0 | 112 | |
michael@0 | 113 | virtual bool Update(gfx::DataSourceSurface* aSurface, |
michael@0 | 114 | nsIntRegion* aDestRegion = nullptr, |
michael@0 | 115 | gfx::IntPoint* aSrcOffset = nullptr) MOZ_OVERRIDE; |
michael@0 | 116 | |
michael@0 | 117 | // TextureSource |
michael@0 | 118 | |
michael@0 | 119 | virtual TextureSourceD3D11* AsSourceD3D11() MOZ_OVERRIDE { return this; } |
michael@0 | 120 | |
michael@0 | 121 | virtual ID3D11Texture2D* GetD3D11Texture() const MOZ_OVERRIDE; |
michael@0 | 122 | |
michael@0 | 123 | virtual DataTextureSource* AsDataTextureSource() MOZ_OVERRIDE { return this; } |
michael@0 | 124 | |
michael@0 | 125 | virtual void DeallocateDeviceData() MOZ_OVERRIDE { mTexture = nullptr; } |
michael@0 | 126 | |
michael@0 | 127 | virtual gfx::IntSize GetSize() const MOZ_OVERRIDE { return mSize; } |
michael@0 | 128 | |
michael@0 | 129 | virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { return mFormat; } |
michael@0 | 130 | |
michael@0 | 131 | virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE; |
michael@0 | 132 | |
michael@0 | 133 | // TileIterator |
michael@0 | 134 | |
michael@0 | 135 | virtual TileIterator* AsTileIterator() MOZ_OVERRIDE { return mIsTiled ? this : nullptr; } |
michael@0 | 136 | |
michael@0 | 137 | virtual size_t GetTileCount() MOZ_OVERRIDE { return mTileTextures.size(); } |
michael@0 | 138 | |
michael@0 | 139 | virtual bool NextTile() MOZ_OVERRIDE { return (++mCurrentTile < mTileTextures.size()); } |
michael@0 | 140 | |
michael@0 | 141 | virtual nsIntRect GetTileRect() MOZ_OVERRIDE; |
michael@0 | 142 | |
michael@0 | 143 | virtual void EndTileIteration() MOZ_OVERRIDE { mIterating = false; } |
michael@0 | 144 | |
michael@0 | 145 | virtual void BeginTileIteration() MOZ_OVERRIDE |
michael@0 | 146 | { |
michael@0 | 147 | mIterating = true; |
michael@0 | 148 | mCurrentTile = 0; |
michael@0 | 149 | } |
michael@0 | 150 | |
michael@0 | 151 | protected: |
michael@0 | 152 | gfx::IntRect GetTileRect(uint32_t aIndex) const; |
michael@0 | 153 | |
michael@0 | 154 | void Reset(); |
michael@0 | 155 | |
michael@0 | 156 | std::vector< RefPtr<ID3D11Texture2D> > mTileTextures; |
michael@0 | 157 | RefPtr<CompositorD3D11> mCompositor; |
michael@0 | 158 | gfx::SurfaceFormat mFormat; |
michael@0 | 159 | TextureFlags mFlags; |
michael@0 | 160 | uint32_t mCurrentTile; |
michael@0 | 161 | bool mIsTiled; |
michael@0 | 162 | bool mIterating; |
michael@0 | 163 | |
michael@0 | 164 | }; |
michael@0 | 165 | |
michael@0 | 166 | /** |
michael@0 | 167 | * A TextureHost for shared D3D11 textures. |
michael@0 | 168 | */ |
michael@0 | 169 | class DXGITextureHostD3D11 : public TextureHost |
michael@0 | 170 | { |
michael@0 | 171 | public: |
michael@0 | 172 | DXGITextureHostD3D11(TextureFlags aFlags, |
michael@0 | 173 | const SurfaceDescriptorD3D10& aDescriptor); |
michael@0 | 174 | |
michael@0 | 175 | virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE; |
michael@0 | 176 | |
michael@0 | 177 | virtual void DeallocateDeviceData() MOZ_OVERRIDE {} |
michael@0 | 178 | |
michael@0 | 179 | virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE; |
michael@0 | 180 | |
michael@0 | 181 | virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { return mFormat; } |
michael@0 | 182 | |
michael@0 | 183 | virtual bool Lock() MOZ_OVERRIDE; |
michael@0 | 184 | |
michael@0 | 185 | virtual void Unlock() MOZ_OVERRIDE; |
michael@0 | 186 | |
michael@0 | 187 | virtual gfx::IntSize GetSize() const MOZ_OVERRIDE { return mSize; } |
michael@0 | 188 | |
michael@0 | 189 | virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE |
michael@0 | 190 | { |
michael@0 | 191 | return nullptr; |
michael@0 | 192 | } |
michael@0 | 193 | |
michael@0 | 194 | protected: |
michael@0 | 195 | ID3D11Device* GetDevice(); |
michael@0 | 196 | |
michael@0 | 197 | RefPtr<DataTextureSourceD3D11> mTextureSource; |
michael@0 | 198 | RefPtr<CompositorD3D11> mCompositor; |
michael@0 | 199 | gfx::IntSize mSize; |
michael@0 | 200 | WindowsHandle mHandle; |
michael@0 | 201 | gfx::SurfaceFormat mFormat; |
michael@0 | 202 | bool mIsLocked; |
michael@0 | 203 | }; |
michael@0 | 204 | |
michael@0 | 205 | class CompositingRenderTargetD3D11 : public CompositingRenderTarget, |
michael@0 | 206 | public TextureSourceD3D11 |
michael@0 | 207 | { |
michael@0 | 208 | public: |
michael@0 | 209 | CompositingRenderTargetD3D11(ID3D11Texture2D* aTexture, |
michael@0 | 210 | const gfx::IntPoint& aOrigin); |
michael@0 | 211 | |
michael@0 | 212 | virtual TextureSourceD3D11* AsSourceD3D11() MOZ_OVERRIDE { return this; } |
michael@0 | 213 | |
michael@0 | 214 | virtual gfx::IntSize GetSize() const MOZ_OVERRIDE; |
michael@0 | 215 | |
michael@0 | 216 | void SetSize(const gfx::IntSize& aSize) { mSize = aSize; } |
michael@0 | 217 | |
michael@0 | 218 | private: |
michael@0 | 219 | friend class CompositorD3D11; |
michael@0 | 220 | |
michael@0 | 221 | RefPtr<ID3D11RenderTargetView> mRTView; |
michael@0 | 222 | }; |
michael@0 | 223 | |
michael@0 | 224 | inline uint32_t GetMaxTextureSizeForFeatureLevel(D3D_FEATURE_LEVEL aFeatureLevel) |
michael@0 | 225 | { |
michael@0 | 226 | int32_t maxTextureSize; |
michael@0 | 227 | switch (aFeatureLevel) { |
michael@0 | 228 | case D3D_FEATURE_LEVEL_11_1: |
michael@0 | 229 | case D3D_FEATURE_LEVEL_11_0: |
michael@0 | 230 | maxTextureSize = D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION; |
michael@0 | 231 | break; |
michael@0 | 232 | case D3D_FEATURE_LEVEL_10_1: |
michael@0 | 233 | case D3D_FEATURE_LEVEL_10_0: |
michael@0 | 234 | maxTextureSize = D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION; |
michael@0 | 235 | break; |
michael@0 | 236 | case D3D_FEATURE_LEVEL_9_3: |
michael@0 | 237 | maxTextureSize = D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION; |
michael@0 | 238 | break; |
michael@0 | 239 | default: |
michael@0 | 240 | maxTextureSize = D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION; |
michael@0 | 241 | } |
michael@0 | 242 | return maxTextureSize; |
michael@0 | 243 | } |
michael@0 | 244 | |
michael@0 | 245 | } |
michael@0 | 246 | } |
michael@0 | 247 | |
michael@0 | 248 | #endif /* MOZILLA_GFX_TEXTURED3D11_H */ |