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_TEXTURED3D9_H |
michael@0 | 7 | #define MOZILLA_GFX_TEXTURED3D9_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 "mozilla/GfxMessageUtils.h" |
michael@0 | 13 | #include "gfxWindowsPlatform.h" |
michael@0 | 14 | #include "d3d9.h" |
michael@0 | 15 | #include <vector> |
michael@0 | 16 | #include "DeviceManagerD3D9.h" |
michael@0 | 17 | |
michael@0 | 18 | namespace mozilla { |
michael@0 | 19 | namespace gfxs { |
michael@0 | 20 | class DrawTarget; |
michael@0 | 21 | } |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | namespace mozilla { |
michael@0 | 25 | namespace layers { |
michael@0 | 26 | |
michael@0 | 27 | class CompositorD3D9; |
michael@0 | 28 | |
michael@0 | 29 | class TextureSourceD3D9 |
michael@0 | 30 | { |
michael@0 | 31 | friend class DeviceManagerD3D9; |
michael@0 | 32 | |
michael@0 | 33 | public: |
michael@0 | 34 | TextureSourceD3D9() |
michael@0 | 35 | : mPreviousHost(nullptr) |
michael@0 | 36 | , mNextHost(nullptr) |
michael@0 | 37 | , mCreatingDeviceManager(nullptr) |
michael@0 | 38 | {} |
michael@0 | 39 | virtual ~TextureSourceD3D9(); |
michael@0 | 40 | |
michael@0 | 41 | virtual IDirect3DTexture9* GetD3D9Texture() { return mTexture; } |
michael@0 | 42 | |
michael@0 | 43 | StereoMode GetStereoMode() const { return mStereoMode; }; |
michael@0 | 44 | |
michael@0 | 45 | // Release all texture memory resources held by the texture host. |
michael@0 | 46 | virtual void ReleaseTextureResources() |
michael@0 | 47 | { |
michael@0 | 48 | mTexture = nullptr; |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | protected: |
michael@0 | 52 | virtual gfx::IntSize GetSize() const { return mSize; } |
michael@0 | 53 | void SetSize(const gfx::IntSize& aSize) { mSize = aSize; } |
michael@0 | 54 | |
michael@0 | 55 | // Helper methods for creating and copying textures. |
michael@0 | 56 | TemporaryRef<IDirect3DTexture9> InitTextures( |
michael@0 | 57 | DeviceManagerD3D9* aDeviceManager, |
michael@0 | 58 | const gfx::IntSize &aSize, |
michael@0 | 59 | _D3DFORMAT aFormat, |
michael@0 | 60 | RefPtr<IDirect3DSurface9>& aSurface, |
michael@0 | 61 | D3DLOCKED_RECT& aLockedRect); |
michael@0 | 62 | |
michael@0 | 63 | TemporaryRef<IDirect3DTexture9> DataToTexture( |
michael@0 | 64 | DeviceManagerD3D9* aDeviceManager, |
michael@0 | 65 | unsigned char *aData, |
michael@0 | 66 | int aStride, |
michael@0 | 67 | const gfx::IntSize &aSize, |
michael@0 | 68 | _D3DFORMAT aFormat, |
michael@0 | 69 | uint32_t aBPP); |
michael@0 | 70 | |
michael@0 | 71 | // aTexture should be in SYSTEMMEM, returns a texture in the default |
michael@0 | 72 | // pool (that is, in video memory). |
michael@0 | 73 | TemporaryRef<IDirect3DTexture9> TextureToTexture( |
michael@0 | 74 | DeviceManagerD3D9* aDeviceManager, |
michael@0 | 75 | IDirect3DTexture9* aTexture, |
michael@0 | 76 | const gfx::IntSize& aSize, |
michael@0 | 77 | _D3DFORMAT aFormat); |
michael@0 | 78 | |
michael@0 | 79 | TemporaryRef<IDirect3DTexture9> SurfaceToTexture( |
michael@0 | 80 | DeviceManagerD3D9* aDeviceManager, |
michael@0 | 81 | gfxWindowsSurface* aSurface, |
michael@0 | 82 | const gfx::IntSize& aSize, |
michael@0 | 83 | _D3DFORMAT aFormat); |
michael@0 | 84 | |
michael@0 | 85 | gfx::IntSize mSize; |
michael@0 | 86 | |
michael@0 | 87 | // Linked list of all objects holding d3d9 textures. |
michael@0 | 88 | TextureSourceD3D9* mPreviousHost; |
michael@0 | 89 | TextureSourceD3D9* mNextHost; |
michael@0 | 90 | // The device manager that created our textures. |
michael@0 | 91 | DeviceManagerD3D9* mCreatingDeviceManager; |
michael@0 | 92 | |
michael@0 | 93 | StereoMode mStereoMode; |
michael@0 | 94 | RefPtr<IDirect3DTexture9> mTexture; |
michael@0 | 95 | }; |
michael@0 | 96 | |
michael@0 | 97 | /** |
michael@0 | 98 | * A TextureSource that implements the DataTextureSource interface. |
michael@0 | 99 | * it can be used without a TextureHost and is able to upload texture data |
michael@0 | 100 | * from a gfx::DataSourceSurface. |
michael@0 | 101 | */ |
michael@0 | 102 | class DataTextureSourceD3D9 : public DataTextureSource |
michael@0 | 103 | , public TextureSourceD3D9 |
michael@0 | 104 | , public TileIterator |
michael@0 | 105 | { |
michael@0 | 106 | public: |
michael@0 | 107 | DataTextureSourceD3D9(gfx::SurfaceFormat aFormat, |
michael@0 | 108 | CompositorD3D9* aCompositor, |
michael@0 | 109 | TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT, |
michael@0 | 110 | StereoMode aStereoMode = StereoMode::MONO); |
michael@0 | 111 | |
michael@0 | 112 | DataTextureSourceD3D9(gfx::SurfaceFormat aFormat, |
michael@0 | 113 | gfx::IntSize aSize, |
michael@0 | 114 | CompositorD3D9* aCompositor, |
michael@0 | 115 | IDirect3DTexture9* aTexture, |
michael@0 | 116 | TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT); |
michael@0 | 117 | |
michael@0 | 118 | virtual ~DataTextureSourceD3D9(); |
michael@0 | 119 | |
michael@0 | 120 | // DataTextureSource |
michael@0 | 121 | |
michael@0 | 122 | virtual bool Update(gfx::DataSourceSurface* aSurface, |
michael@0 | 123 | nsIntRegion* aDestRegion = nullptr, |
michael@0 | 124 | gfx::IntPoint* aSrcOffset = nullptr) MOZ_OVERRIDE; |
michael@0 | 125 | |
michael@0 | 126 | // TextureSource |
michael@0 | 127 | |
michael@0 | 128 | virtual TextureSourceD3D9* AsSourceD3D9() MOZ_OVERRIDE { return this; } |
michael@0 | 129 | |
michael@0 | 130 | virtual IDirect3DTexture9* GetD3D9Texture() MOZ_OVERRIDE; |
michael@0 | 131 | |
michael@0 | 132 | virtual DataTextureSource* AsDataTextureSource() MOZ_OVERRIDE { return this; } |
michael@0 | 133 | |
michael@0 | 134 | virtual void DeallocateDeviceData() MOZ_OVERRIDE { mTexture = nullptr; } |
michael@0 | 135 | |
michael@0 | 136 | virtual gfx::IntSize GetSize() const MOZ_OVERRIDE { return mSize; } |
michael@0 | 137 | |
michael@0 | 138 | virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { return mFormat; } |
michael@0 | 139 | |
michael@0 | 140 | virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE; |
michael@0 | 141 | |
michael@0 | 142 | // TileIterator |
michael@0 | 143 | |
michael@0 | 144 | virtual TileIterator* AsTileIterator() MOZ_OVERRIDE { return mIsTiled ? this : nullptr; } |
michael@0 | 145 | |
michael@0 | 146 | virtual size_t GetTileCount() MOZ_OVERRIDE { return mTileTextures.size(); } |
michael@0 | 147 | |
michael@0 | 148 | virtual bool NextTile() MOZ_OVERRIDE { return (++mCurrentTile < mTileTextures.size()); } |
michael@0 | 149 | |
michael@0 | 150 | virtual nsIntRect GetTileRect() MOZ_OVERRIDE; |
michael@0 | 151 | |
michael@0 | 152 | virtual void EndTileIteration() MOZ_OVERRIDE { mIterating = false; } |
michael@0 | 153 | |
michael@0 | 154 | virtual void BeginTileIteration() MOZ_OVERRIDE |
michael@0 | 155 | { |
michael@0 | 156 | mIterating = true; |
michael@0 | 157 | mCurrentTile = 0; |
michael@0 | 158 | } |
michael@0 | 159 | |
michael@0 | 160 | /** |
michael@0 | 161 | * Copy the content of aTexture using the GPU. |
michael@0 | 162 | */ |
michael@0 | 163 | bool UpdateFromTexture(IDirect3DTexture9* aTexture, const nsIntRegion* aRegion); |
michael@0 | 164 | |
michael@0 | 165 | // To use with DIBTextureHostD3D9 |
michael@0 | 166 | |
michael@0 | 167 | bool Update(gfxWindowsSurface* aSurface); |
michael@0 | 168 | |
michael@0 | 169 | protected: |
michael@0 | 170 | gfx::IntRect GetTileRect(uint32_t aTileIndex) const; |
michael@0 | 171 | |
michael@0 | 172 | void Reset(); |
michael@0 | 173 | |
michael@0 | 174 | std::vector< RefPtr<IDirect3DTexture9> > mTileTextures; |
michael@0 | 175 | RefPtr<CompositorD3D9> mCompositor; |
michael@0 | 176 | gfx::SurfaceFormat mFormat; |
michael@0 | 177 | uint32_t mCurrentTile; |
michael@0 | 178 | TextureFlags mFlags; |
michael@0 | 179 | bool mIsTiled; |
michael@0 | 180 | bool mIterating; |
michael@0 | 181 | }; |
michael@0 | 182 | |
michael@0 | 183 | /** |
michael@0 | 184 | * Can only be drawn into through Cairo and need a D3D9 context on the client side. |
michael@0 | 185 | * The corresponding TextureHost is TextureHostD3D9. |
michael@0 | 186 | */ |
michael@0 | 187 | class CairoTextureClientD3D9 : public TextureClient |
michael@0 | 188 | { |
michael@0 | 189 | public: |
michael@0 | 190 | CairoTextureClientD3D9(gfx::SurfaceFormat aFormat, TextureFlags aFlags); |
michael@0 | 191 | |
michael@0 | 192 | virtual ~CairoTextureClientD3D9(); |
michael@0 | 193 | |
michael@0 | 194 | // TextureClient |
michael@0 | 195 | |
michael@0 | 196 | virtual bool IsAllocated() const MOZ_OVERRIDE { return !!mTexture; } |
michael@0 | 197 | |
michael@0 | 198 | virtual bool Lock(OpenMode aOpenMode) MOZ_OVERRIDE; |
michael@0 | 199 | |
michael@0 | 200 | virtual void Unlock() MOZ_OVERRIDE; |
michael@0 | 201 | |
michael@0 | 202 | virtual bool IsLocked() const MOZ_OVERRIDE { return mIsLocked; } |
michael@0 | 203 | |
michael@0 | 204 | virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) MOZ_OVERRIDE; |
michael@0 | 205 | |
michael@0 | 206 | virtual gfx::IntSize GetSize() const { return mSize; } |
michael@0 | 207 | |
michael@0 | 208 | virtual gfx::SurfaceFormat GetFormat() const { return mFormat; } |
michael@0 | 209 | |
michael@0 | 210 | virtual TextureClientData* DropTextureData() MOZ_OVERRIDE; |
michael@0 | 211 | |
michael@0 | 212 | virtual bool CanExposeDrawTarget() const MOZ_OVERRIDE { return true; } |
michael@0 | 213 | |
michael@0 | 214 | virtual TemporaryRef<gfx::DrawTarget> GetAsDrawTarget() MOZ_OVERRIDE; |
michael@0 | 215 | |
michael@0 | 216 | virtual bool AllocateForSurface(gfx::IntSize aSize, |
michael@0 | 217 | TextureAllocationFlags aFlags = ALLOC_DEFAULT) MOZ_OVERRIDE; |
michael@0 | 218 | |
michael@0 | 219 | virtual bool HasInternalBuffer() const MOZ_OVERRIDE { return true; } |
michael@0 | 220 | |
michael@0 | 221 | private: |
michael@0 | 222 | RefPtr<IDirect3DTexture9> mTexture; |
michael@0 | 223 | nsRefPtr<IDirect3DSurface9> mD3D9Surface; |
michael@0 | 224 | RefPtr<gfx::DrawTarget> mDrawTarget; |
michael@0 | 225 | nsRefPtr<gfxASurface> mSurface; |
michael@0 | 226 | gfx::IntSize mSize; |
michael@0 | 227 | gfx::SurfaceFormat mFormat; |
michael@0 | 228 | bool mIsLocked; |
michael@0 | 229 | bool mNeedsClear; |
michael@0 | 230 | bool mLockRect; |
michael@0 | 231 | }; |
michael@0 | 232 | |
michael@0 | 233 | /** |
michael@0 | 234 | * Can only be drawn into through Cairo. |
michael@0 | 235 | * Prefer CairoTextureClientD3D9 when possible. |
michael@0 | 236 | * The coresponding TextureHost is DIBTextureHostD3D9. |
michael@0 | 237 | */ |
michael@0 | 238 | class DIBTextureClientD3D9 : public TextureClient |
michael@0 | 239 | { |
michael@0 | 240 | public: |
michael@0 | 241 | DIBTextureClientD3D9(gfx::SurfaceFormat aFormat, TextureFlags aFlags); |
michael@0 | 242 | |
michael@0 | 243 | virtual ~DIBTextureClientD3D9(); |
michael@0 | 244 | |
michael@0 | 245 | // TextureClient |
michael@0 | 246 | |
michael@0 | 247 | virtual bool IsAllocated() const MOZ_OVERRIDE { return !!mSurface; } |
michael@0 | 248 | |
michael@0 | 249 | virtual bool Lock(OpenMode aOpenMode) MOZ_OVERRIDE; |
michael@0 | 250 | |
michael@0 | 251 | virtual void Unlock() MOZ_OVERRIDE; |
michael@0 | 252 | |
michael@0 | 253 | virtual bool IsLocked() const MOZ_OVERRIDE { return mIsLocked; } |
michael@0 | 254 | |
michael@0 | 255 | virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) MOZ_OVERRIDE; |
michael@0 | 256 | |
michael@0 | 257 | virtual gfx::IntSize GetSize() const { return mSize; } |
michael@0 | 258 | |
michael@0 | 259 | virtual gfx::SurfaceFormat GetFormat() const { return mFormat; } |
michael@0 | 260 | |
michael@0 | 261 | virtual TextureClientData* DropTextureData() MOZ_OVERRIDE; |
michael@0 | 262 | |
michael@0 | 263 | virtual bool CanExposeDrawTarget() const MOZ_OVERRIDE { return true; } |
michael@0 | 264 | |
michael@0 | 265 | virtual TemporaryRef<gfx::DrawTarget> GetAsDrawTarget() MOZ_OVERRIDE; |
michael@0 | 266 | |
michael@0 | 267 | virtual bool AllocateForSurface(gfx::IntSize aSize, |
michael@0 | 268 | TextureAllocationFlags aFlags = ALLOC_DEFAULT) MOZ_OVERRIDE; |
michael@0 | 269 | |
michael@0 | 270 | virtual bool HasInternalBuffer() const MOZ_OVERRIDE { return true; } |
michael@0 | 271 | |
michael@0 | 272 | protected: |
michael@0 | 273 | nsRefPtr<gfxWindowsSurface> mSurface; |
michael@0 | 274 | RefPtr<gfx::DrawTarget> mDrawTarget; |
michael@0 | 275 | gfx::IntSize mSize; |
michael@0 | 276 | gfx::SurfaceFormat mFormat; |
michael@0 | 277 | bool mIsLocked; |
michael@0 | 278 | }; |
michael@0 | 279 | |
michael@0 | 280 | /** |
michael@0 | 281 | * Wraps a D3D9 texture, shared with the compositor though DXGI. |
michael@0 | 282 | * At the moment it is only used with D3D11 compositing, and the corresponding |
michael@0 | 283 | * TextureHost is DXGITextureHostD3D11. |
michael@0 | 284 | */ |
michael@0 | 285 | class SharedTextureClientD3D9 : public TextureClient |
michael@0 | 286 | { |
michael@0 | 287 | public: |
michael@0 | 288 | SharedTextureClientD3D9(gfx::SurfaceFormat aFormat, TextureFlags aFlags); |
michael@0 | 289 | |
michael@0 | 290 | virtual ~SharedTextureClientD3D9(); |
michael@0 | 291 | |
michael@0 | 292 | // TextureClient |
michael@0 | 293 | |
michael@0 | 294 | virtual bool IsAllocated() const MOZ_OVERRIDE { return !!mTexture; } |
michael@0 | 295 | |
michael@0 | 296 | virtual bool Lock(OpenMode aOpenMode) MOZ_OVERRIDE; |
michael@0 | 297 | |
michael@0 | 298 | virtual void Unlock() MOZ_OVERRIDE; |
michael@0 | 299 | |
michael@0 | 300 | virtual bool IsLocked() const MOZ_OVERRIDE { return mIsLocked; } |
michael@0 | 301 | |
michael@0 | 302 | virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) MOZ_OVERRIDE; |
michael@0 | 303 | |
michael@0 | 304 | void InitWith(IDirect3DTexture9* aTexture, HANDLE aSharedHandle, D3DSURFACE_DESC aDesc) |
michael@0 | 305 | { |
michael@0 | 306 | MOZ_ASSERT(!mTexture); |
michael@0 | 307 | mTexture = aTexture; |
michael@0 | 308 | mHandle = aSharedHandle; |
michael@0 | 309 | mDesc = aDesc; |
michael@0 | 310 | } |
michael@0 | 311 | |
michael@0 | 312 | virtual gfx::IntSize GetSize() const |
michael@0 | 313 | { |
michael@0 | 314 | return gfx::IntSize(mDesc.Width, mDesc.Height); |
michael@0 | 315 | } |
michael@0 | 316 | |
michael@0 | 317 | virtual TextureClientData* DropTextureData() MOZ_OVERRIDE; |
michael@0 | 318 | |
michael@0 | 319 | virtual bool HasInternalBuffer() const MOZ_OVERRIDE { return true; } |
michael@0 | 320 | |
michael@0 | 321 | private: |
michael@0 | 322 | RefPtr<IDirect3DTexture9> mTexture; |
michael@0 | 323 | gfx::SurfaceFormat mFormat; |
michael@0 | 324 | HANDLE mHandle; |
michael@0 | 325 | D3DSURFACE_DESC mDesc; |
michael@0 | 326 | bool mIsLocked; |
michael@0 | 327 | }; |
michael@0 | 328 | |
michael@0 | 329 | class TextureHostD3D9 : public TextureHost |
michael@0 | 330 | { |
michael@0 | 331 | public: |
michael@0 | 332 | TextureHostD3D9(TextureFlags aFlags, |
michael@0 | 333 | const SurfaceDescriptorD3D9& aDescriptor); |
michael@0 | 334 | |
michael@0 | 335 | virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE; |
michael@0 | 336 | |
michael@0 | 337 | virtual void DeallocateDeviceData() MOZ_OVERRIDE; |
michael@0 | 338 | |
michael@0 | 339 | virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE; |
michael@0 | 340 | |
michael@0 | 341 | virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { return mFormat; } |
michael@0 | 342 | |
michael@0 | 343 | virtual bool Lock() MOZ_OVERRIDE; |
michael@0 | 344 | |
michael@0 | 345 | virtual void Unlock() MOZ_OVERRIDE; |
michael@0 | 346 | |
michael@0 | 347 | virtual void Updated(const nsIntRegion* aRegion) MOZ_OVERRIDE; |
michael@0 | 348 | |
michael@0 | 349 | virtual gfx::IntSize GetSize() const MOZ_OVERRIDE { return mSize; } |
michael@0 | 350 | |
michael@0 | 351 | virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE |
michael@0 | 352 | { |
michael@0 | 353 | return nullptr; |
michael@0 | 354 | } |
michael@0 | 355 | |
michael@0 | 356 | virtual bool HasInternalBuffer() const MOZ_OVERRIDE { return true; } |
michael@0 | 357 | |
michael@0 | 358 | protected: |
michael@0 | 359 | TextureHostD3D9(TextureFlags aFlags); |
michael@0 | 360 | IDirect3DDevice9* GetDevice(); |
michael@0 | 361 | |
michael@0 | 362 | RefPtr<DataTextureSourceD3D9> mTextureSource; |
michael@0 | 363 | RefPtr<IDirect3DTexture9> mTexture; |
michael@0 | 364 | RefPtr<CompositorD3D9> mCompositor; |
michael@0 | 365 | gfx::IntSize mSize; |
michael@0 | 366 | gfx::SurfaceFormat mFormat; |
michael@0 | 367 | bool mIsLocked; |
michael@0 | 368 | }; |
michael@0 | 369 | |
michael@0 | 370 | class DIBTextureHostD3D9 : public TextureHost |
michael@0 | 371 | { |
michael@0 | 372 | public: |
michael@0 | 373 | DIBTextureHostD3D9(TextureFlags aFlags, |
michael@0 | 374 | const SurfaceDescriptorDIB& aDescriptor); |
michael@0 | 375 | |
michael@0 | 376 | virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE; |
michael@0 | 377 | |
michael@0 | 378 | virtual void DeallocateDeviceData() MOZ_OVERRIDE; |
michael@0 | 379 | |
michael@0 | 380 | virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE; |
michael@0 | 381 | |
michael@0 | 382 | virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { return mFormat; } |
michael@0 | 383 | |
michael@0 | 384 | virtual gfx::IntSize GetSize() const MOZ_OVERRIDE { return mSize; } |
michael@0 | 385 | |
michael@0 | 386 | virtual bool Lock() MOZ_OVERRIDE; |
michael@0 | 387 | |
michael@0 | 388 | virtual void Unlock() MOZ_OVERRIDE; |
michael@0 | 389 | |
michael@0 | 390 | virtual void Updated(const nsIntRegion* aRegion = nullptr); |
michael@0 | 391 | |
michael@0 | 392 | virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE |
michael@0 | 393 | { |
michael@0 | 394 | return nullptr; // TODO: cf bug 872568 |
michael@0 | 395 | } |
michael@0 | 396 | |
michael@0 | 397 | protected: |
michael@0 | 398 | nsRefPtr<gfxWindowsSurface> mSurface; |
michael@0 | 399 | RefPtr<DataTextureSourceD3D9> mTextureSource; |
michael@0 | 400 | RefPtr<CompositorD3D9> mCompositor; |
michael@0 | 401 | gfx::SurfaceFormat mFormat; |
michael@0 | 402 | gfx::IntSize mSize; |
michael@0 | 403 | bool mIsLocked; |
michael@0 | 404 | }; |
michael@0 | 405 | |
michael@0 | 406 | class DXGITextureHostD3D9 : public TextureHost |
michael@0 | 407 | { |
michael@0 | 408 | public: |
michael@0 | 409 | DXGITextureHostD3D9(TextureFlags aFlags, |
michael@0 | 410 | const SurfaceDescriptorD3D10& aDescriptor); |
michael@0 | 411 | |
michael@0 | 412 | virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE; |
michael@0 | 413 | |
michael@0 | 414 | virtual void DeallocateDeviceData() MOZ_OVERRIDE; |
michael@0 | 415 | |
michael@0 | 416 | virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE; |
michael@0 | 417 | |
michael@0 | 418 | virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { return mFormat; } |
michael@0 | 419 | |
michael@0 | 420 | virtual gfx::IntSize GetSize() const MOZ_OVERRIDE { return mSize; } |
michael@0 | 421 | |
michael@0 | 422 | virtual bool Lock() MOZ_OVERRIDE; |
michael@0 | 423 | |
michael@0 | 424 | virtual void Unlock() MOZ_OVERRIDE; |
michael@0 | 425 | |
michael@0 | 426 | virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE |
michael@0 | 427 | { |
michael@0 | 428 | return nullptr; // TODO: cf bug 872568 |
michael@0 | 429 | } |
michael@0 | 430 | |
michael@0 | 431 | protected: |
michael@0 | 432 | RefPtr<DataTextureSourceD3D9> mTextureSource; |
michael@0 | 433 | RefPtr<CompositorD3D9> mCompositor; |
michael@0 | 434 | WindowsHandle mHandle; |
michael@0 | 435 | gfx::SurfaceFormat mFormat; |
michael@0 | 436 | gfx::IntSize mSize; |
michael@0 | 437 | bool mIsLocked; |
michael@0 | 438 | }; |
michael@0 | 439 | |
michael@0 | 440 | class CompositingRenderTargetD3D9 : public CompositingRenderTarget, |
michael@0 | 441 | public TextureSourceD3D9 |
michael@0 | 442 | { |
michael@0 | 443 | public: |
michael@0 | 444 | CompositingRenderTargetD3D9(IDirect3DTexture9* aTexture, |
michael@0 | 445 | SurfaceInitMode aInit, |
michael@0 | 446 | const gfx::IntRect& aRect); |
michael@0 | 447 | // use for rendering to the main window, cannot be rendered as a texture |
michael@0 | 448 | CompositingRenderTargetD3D9(IDirect3DSurface9* aSurface, |
michael@0 | 449 | SurfaceInitMode aInit, |
michael@0 | 450 | const gfx::IntRect& aRect); |
michael@0 | 451 | virtual ~CompositingRenderTargetD3D9(); |
michael@0 | 452 | |
michael@0 | 453 | virtual TextureSourceD3D9* AsSourceD3D9() MOZ_OVERRIDE |
michael@0 | 454 | { |
michael@0 | 455 | MOZ_ASSERT(mTexture, |
michael@0 | 456 | "No texture, can't be indirectly rendered. Is this the screen backbuffer?"); |
michael@0 | 457 | return this; |
michael@0 | 458 | } |
michael@0 | 459 | |
michael@0 | 460 | virtual gfx::IntSize GetSize() const MOZ_OVERRIDE; |
michael@0 | 461 | |
michael@0 | 462 | void BindRenderTarget(IDirect3DDevice9* aDevice); |
michael@0 | 463 | |
michael@0 | 464 | IDirect3DSurface9* GetD3D9Surface() const { return mSurface; } |
michael@0 | 465 | |
michael@0 | 466 | private: |
michael@0 | 467 | friend class CompositorD3D9; |
michael@0 | 468 | |
michael@0 | 469 | nsRefPtr<IDirect3DSurface9> mSurface; |
michael@0 | 470 | SurfaceInitMode mInitMode; |
michael@0 | 471 | bool mInitialized; |
michael@0 | 472 | }; |
michael@0 | 473 | |
michael@0 | 474 | } |
michael@0 | 475 | } |
michael@0 | 476 | |
michael@0 | 477 | #endif /* MOZILLA_GFX_TEXTURED3D9_H */ |