Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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/. */
6 #ifndef MOZILLA_GFX_MACIOSURFACETEXTUREHOSTOGL_H
7 #define MOZILLA_GFX_MACIOSURFACETEXTUREHOSTOGL_H
9 #include "mozilla/layers/TextureHostOGL.h"
11 class MacIOSurface;
13 namespace mozilla {
14 namespace layers {
16 /**
17 * A texture source meant for use with MacIOSurfaceTextureHostOGL.
18 *
19 * It does not own any GL texture, and attaches its shared handle to one of
20 * the compositor's temporary textures when binding.
21 */
22 class MacIOSurfaceTextureSourceOGL : public NewTextureSource
23 , public TextureSourceOGL
24 {
25 public:
26 MacIOSurfaceTextureSourceOGL(CompositorOGL* aCompositor,
27 MacIOSurface* aSurface);
28 virtual ~MacIOSurfaceTextureSourceOGL();
30 virtual TextureSourceOGL* AsSourceOGL() { return this; }
32 virtual void BindTexture(GLenum activetex, gfx::Filter aFilter) MOZ_OVERRIDE;
34 virtual bool IsValid() const MOZ_OVERRIDE { return !!gl(); }
36 virtual gfx::IntSize GetSize() const MOZ_OVERRIDE;
38 virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE;
40 virtual GLenum GetTextureTarget() const { return LOCAL_GL_TEXTURE_RECTANGLE_ARB; }
42 virtual GLenum GetWrapMode() const MOZ_OVERRIDE { return LOCAL_GL_CLAMP_TO_EDGE; }
44 // MacIOSurfaceTextureSourceOGL doesn't own any gl texture
45 virtual void DeallocateDeviceData() {}
47 virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
49 gl::GLContext* gl() const;
51 protected:
52 CompositorOGL* mCompositor;
53 RefPtr<MacIOSurface> mSurface;
54 };
56 /**
57 * A TextureHost for shared MacIOSurface
58 *
59 * Most of the logic actually happens in MacIOSurfaceTextureSourceOGL.
60 */
61 class MacIOSurfaceTextureHostOGL : public TextureHost
62 {
63 public:
64 MacIOSurfaceTextureHostOGL(TextureFlags aFlags,
65 const SurfaceDescriptorMacIOSurface& aDescriptor);
67 // SharedTextureHostOGL doesn't own any GL texture
68 virtual void DeallocateDeviceData() MOZ_OVERRIDE {}
70 virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
72 virtual bool Lock() MOZ_OVERRIDE;
74 virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE;
76 virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE
77 {
78 return mTextureSource;
79 }
81 virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE
82 {
83 return nullptr; // XXX - implement this (for MOZ_DUMP_PAINTING)
84 }
86 gl::GLContext* gl() const;
88 virtual gfx::IntSize GetSize() const MOZ_OVERRIDE;
90 #ifdef MOZ_LAYERS_HAVE_LOG
91 virtual const char* Name() { return "MacIOSurfaceTextureHostOGL"; }
92 #endif
94 protected:
95 CompositorOGL* mCompositor;
96 RefPtr<MacIOSurfaceTextureSourceOGL> mTextureSource;
97 RefPtr<MacIOSurface> mSurface;
98 };
100 }
101 }
103 #endif // MOZILLA_GFX_MACIOSURFACETEXTUREHOSTOGL_H