Line data Source code
1 : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
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/. */
5 :
6 : #ifndef MOZILLA_GFX_TEXTURECLIENTOGL_H
7 : #define MOZILLA_GFX_TEXTURECLIENTOGL_H
8 :
9 : #include "GLContextTypes.h" // for SharedTextureHandle, etc
10 : #include "GLImages.h"
11 : #include "gfxTypes.h"
12 : #include "mozilla/Attributes.h" // for override
13 : #include "mozilla/gfx/Point.h" // for IntSize
14 : #include "mozilla/layers/CompositorTypes.h"
15 : #include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
16 : #include "mozilla/layers/TextureClient.h" // for TextureClient, etc
17 : #include "AndroidSurfaceTexture.h"
18 :
19 : namespace mozilla {
20 :
21 : namespace layers {
22 :
23 0 : class EGLImageTextureData : public TextureData
24 : {
25 : public:
26 :
27 : static already_AddRefed<TextureClient>
28 : CreateTextureClient(EGLImageImage* aImage, gfx::IntSize aSize,
29 : LayersIPCChannel* aAllocator, TextureFlags aFlags);
30 :
31 : virtual void FillInfo(TextureData::Info& aInfo) const override;
32 :
33 : virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
34 :
35 0 : virtual void Deallocate(LayersIPCChannel*) override { mImage = nullptr; }
36 :
37 0 : virtual void Forget(LayersIPCChannel*) override { mImage = nullptr; }
38 :
39 : // Unused functions.
40 0 : virtual bool Lock(OpenMode) override { return true; }
41 :
42 0 : virtual void Unlock() override {}
43 :
44 : protected:
45 : EGLImageTextureData(EGLImageImage* aImage, gfx::IntSize aSize);
46 :
47 : RefPtr<EGLImageImage> mImage;
48 : const gfx::IntSize mSize;
49 : };
50 :
51 : #ifdef MOZ_WIDGET_ANDROID
52 :
53 : class AndroidSurfaceTextureData : public TextureData
54 : {
55 : public:
56 : static already_AddRefed<TextureClient>
57 : CreateTextureClient(AndroidSurfaceTextureHandle aHandle,
58 : gfx::IntSize aSize,
59 : bool aContinuous,
60 : gl::OriginPos aOriginPos,
61 : LayersIPCChannel* aAllocator,
62 : TextureFlags aFlags);
63 :
64 : ~AndroidSurfaceTextureData();
65 :
66 : virtual void FillInfo(TextureData::Info& aInfo) const override;
67 :
68 : virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
69 :
70 : // Useless functions.
71 : virtual bool Lock(OpenMode) override { return true; }
72 :
73 : virtual void Unlock() override {}
74 :
75 : // Our data is always owned externally.
76 : virtual void Deallocate(LayersIPCChannel*) override {}
77 :
78 : protected:
79 : AndroidSurfaceTextureData(AndroidSurfaceTextureHandle aHandle, gfx::IntSize aSize, bool aContinuous);
80 :
81 : const AndroidSurfaceTextureHandle mHandle;
82 : const gfx::IntSize mSize;
83 : const bool mContinuous;
84 : };
85 :
86 : #endif // MOZ_WIDGET_ANDROID
87 :
88 : } // namespace layers
89 : } // namespace mozilla
90 :
91 : #endif
|