/src/mozilla-central/gfx/layers/BufferTexture.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef MOZILLA_LAYERS_BUFFERETEXTURE |
8 | | #define MOZILLA_LAYERS_BUFFERETEXTURE |
9 | | |
10 | | #include "mozilla/layers/TextureClient.h" |
11 | | #include "mozilla/ipc/SharedMemory.h" |
12 | | #include "mozilla/gfx/Types.h" |
13 | | #include "mozilla/gfx/2D.h" |
14 | | #include "mozilla/RefPtr.h" |
15 | | |
16 | | namespace mozilla { |
17 | | namespace layers { |
18 | | |
19 | | bool ComputeHasIntermediateBuffer(gfx::SurfaceFormat aFormat, |
20 | | LayersBackend aLayersBackend, |
21 | | bool aSupportsTextureDirectMapping); |
22 | | |
23 | | class BufferTextureData : public TextureData |
24 | | { |
25 | | public: |
26 | | static BufferTextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat, |
27 | | gfx::BackendType aMoz2DBackend, |
28 | | LayersBackend aLayersBackend, |
29 | | TextureFlags aFlags, |
30 | | TextureAllocationFlags aAllocFlags, |
31 | | LayersIPCChannel* aAllocator); |
32 | | |
33 | | static BufferTextureData* CreateForYCbCr(KnowsCompositor* aAllocator, |
34 | | gfx::IntSize aYSize, |
35 | | uint32_t aYStride, |
36 | | gfx::IntSize aCbCrSize, |
37 | | uint32_t aCbCrStride, |
38 | | StereoMode aStereoMode, |
39 | | YUVColorSpace aYUVColorSpace, |
40 | | uint32_t aBitDepth, |
41 | | TextureFlags aTextureFlags); |
42 | | |
43 | 0 | virtual bool Lock(OpenMode aMode) override { return true; } |
44 | | |
45 | 0 | virtual void Unlock() override {} |
46 | | |
47 | | virtual void FillInfo(TextureData::Info& aInfo) const override; |
48 | | |
49 | | virtual already_AddRefed<gfx::DrawTarget> BorrowDrawTarget() override; |
50 | | |
51 | | virtual bool BorrowMappedData(MappedTextureData& aMap) override; |
52 | | |
53 | | virtual bool BorrowMappedYCbCrData(MappedYCbCrTextureData& aMap) override; |
54 | | |
55 | | // use TextureClient's default implementation |
56 | | virtual bool UpdateFromSurface(gfx::SourceSurface* aSurface) override; |
57 | | |
58 | 0 | virtual BufferTextureData* AsBufferTextureData() override { return this; } |
59 | | |
60 | | // Don't use this. |
61 | | void SetDesciptor(const BufferDescriptor& aDesc); |
62 | | |
63 | | Maybe<gfx::IntSize> GetCbCrSize() const; |
64 | | |
65 | | Maybe<YUVColorSpace> GetYUVColorSpace() const; |
66 | | |
67 | | Maybe<uint32_t> GetBitDepth() const; |
68 | | |
69 | | Maybe<StereoMode> GetStereoMode() const; |
70 | | |
71 | | protected: |
72 | | gfx::IntSize GetSize() const; |
73 | | |
74 | | gfx::SurfaceFormat GetFormat() const; |
75 | | |
76 | | static BufferTextureData* CreateInternal(LayersIPCChannel* aAllocator, |
77 | | const BufferDescriptor& aDesc, |
78 | | gfx::BackendType aMoz2DBackend, |
79 | | int32_t aBufferSize, |
80 | | TextureFlags aTextureFlags); |
81 | | |
82 | | virtual uint8_t* GetBuffer() = 0; |
83 | | virtual size_t GetBufferSize() = 0; |
84 | | |
85 | | BufferTextureData(const BufferDescriptor& aDescriptor, gfx::BackendType aMoz2DBackend) |
86 | | : mDescriptor(aDescriptor) |
87 | | , mMoz2DBackend(aMoz2DBackend) |
88 | 0 | {} |
89 | | |
90 | | RefPtr<gfx::DrawTarget> mDrawTarget; |
91 | | BufferDescriptor mDescriptor; |
92 | | gfx::BackendType mMoz2DBackend; |
93 | | }; |
94 | | |
95 | | } // namespace |
96 | | } // namespace |
97 | | |
98 | | #endif |