Bumping manifests a=b2g-bump
[gecko.git] / gfx / layers / TextureDIB.h
blob27df1e93a704ac001520bb48d101ccf1018b358c
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
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_TEXTUREDIB_H
7 #define MOZILLA_GFX_TEXTUREDIB_H
9 #include "mozilla/layers/Compositor.h"
10 #include "mozilla/layers/TextureClient.h"
11 #include "mozilla/layers/TextureHost.h"
12 #include "mozilla/GfxMessageUtils.h"
13 #include "gfxWindowsPlatform.h"
15 namespace mozilla {
16 namespace layers {
18 /**
19 * Can only be drawn into through Cairo.
20 * Prefer CairoTextureClient when possible.
21 * The coresponding TextureHost depends on the compositor
23 class DIBTextureClient : public TextureClient
25 public:
26 DIBTextureClient(ISurfaceAllocator* aAllocator,
27 gfx::SurfaceFormat aFormat,
28 TextureFlags aFlags);
30 virtual ~DIBTextureClient();
32 // TextureClient
34 virtual bool IsAllocated() const MOZ_OVERRIDE { return !!mSurface; }
36 virtual bool Lock(OpenMode aOpenMode) MOZ_OVERRIDE;
38 virtual void Unlock() MOZ_OVERRIDE;
40 virtual bool IsLocked() const MOZ_OVERRIDE{ return mIsLocked; }
42 virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) MOZ_OVERRIDE;
44 virtual gfx::IntSize GetSize() const MOZ_OVERRIDE { return mSize; }
46 virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { return mFormat; }
48 virtual bool CanExposeDrawTarget() const MOZ_OVERRIDE { return true; }
50 virtual gfx::DrawTarget* BorrowDrawTarget() MOZ_OVERRIDE;
52 virtual bool AllocateForSurface(gfx::IntSize aSize,
53 TextureAllocationFlags aFlags = ALLOC_DEFAULT) MOZ_OVERRIDE;
55 virtual bool HasInternalBuffer() const MOZ_OVERRIDE { return true; }
57 virtual TemporaryRef<TextureClient>
58 CreateSimilar(TextureFlags aFlags = TextureFlags::DEFAULT,
59 TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const MOZ_OVERRIDE;
61 protected:
62 nsRefPtr<gfxWindowsSurface> mSurface;
63 RefPtr<gfx::DrawTarget> mDrawTarget;
64 gfx::IntSize mSize;
65 gfx::SurfaceFormat mFormat;
66 bool mIsLocked;
69 class DIBTextureHost : public TextureHost
71 public:
72 DIBTextureHost(TextureFlags aFlags,
73 const SurfaceDescriptorDIB& aDescriptor);
75 virtual TextureSource* GetTextureSources() MOZ_OVERRIDE;
77 virtual void DeallocateDeviceData() MOZ_OVERRIDE;
79 virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
81 virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { return mFormat; }
83 virtual gfx::IntSize GetSize() const MOZ_OVERRIDE { return mSize; }
85 virtual bool Lock() MOZ_OVERRIDE;
87 virtual void Unlock() MOZ_OVERRIDE;
89 virtual void Updated(const nsIntRegion* aRegion = nullptr) MOZ_OVERRIDE;
91 virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE
93 return nullptr; // TODO: cf bug 872568
96 protected:
97 nsRefPtr<gfxWindowsSurface> mSurface;
98 RefPtr<DataTextureSource> mTextureSource;
99 RefPtr<Compositor> mCompositor;
100 gfx::SurfaceFormat mFormat;
101 gfx::IntSize mSize;
102 bool mIsLocked;
108 #endif /* MOZILLA_GFX_TEXTUREDIB_H */