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"
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
26 DIBTextureClient(ISurfaceAllocator
* aAllocator
,
27 gfx::SurfaceFormat aFormat
,
30 virtual ~DIBTextureClient();
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
;
62 nsRefPtr
<gfxWindowsSurface
> mSurface
;
63 RefPtr
<gfx::DrawTarget
> mDrawTarget
;
65 gfx::SurfaceFormat mFormat
;
69 class DIBTextureHost
: public TextureHost
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
97 nsRefPtr
<gfxWindowsSurface
> mSurface
;
98 RefPtr
<DataTextureSource
> mTextureSource
;
99 RefPtr
<Compositor
> mCompositor
;
100 gfx::SurfaceFormat mFormat
;
108 #endif /* MOZILLA_GFX_TEXTUREDIB_H */