Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef MOZILLA_GFX_MACIOSURFACETEXTUREHOSTOGL_H |
michael@0 | 7 | #define MOZILLA_GFX_MACIOSURFACETEXTUREHOSTOGL_H |
michael@0 | 8 | |
michael@0 | 9 | #include "mozilla/layers/TextureHostOGL.h" |
michael@0 | 10 | |
michael@0 | 11 | class MacIOSurface; |
michael@0 | 12 | |
michael@0 | 13 | namespace mozilla { |
michael@0 | 14 | namespace layers { |
michael@0 | 15 | |
michael@0 | 16 | /** |
michael@0 | 17 | * A texture source meant for use with MacIOSurfaceTextureHostOGL. |
michael@0 | 18 | * |
michael@0 | 19 | * It does not own any GL texture, and attaches its shared handle to one of |
michael@0 | 20 | * the compositor's temporary textures when binding. |
michael@0 | 21 | */ |
michael@0 | 22 | class MacIOSurfaceTextureSourceOGL : public NewTextureSource |
michael@0 | 23 | , public TextureSourceOGL |
michael@0 | 24 | { |
michael@0 | 25 | public: |
michael@0 | 26 | MacIOSurfaceTextureSourceOGL(CompositorOGL* aCompositor, |
michael@0 | 27 | MacIOSurface* aSurface); |
michael@0 | 28 | virtual ~MacIOSurfaceTextureSourceOGL(); |
michael@0 | 29 | |
michael@0 | 30 | virtual TextureSourceOGL* AsSourceOGL() { return this; } |
michael@0 | 31 | |
michael@0 | 32 | virtual void BindTexture(GLenum activetex, gfx::Filter aFilter) MOZ_OVERRIDE; |
michael@0 | 33 | |
michael@0 | 34 | virtual bool IsValid() const MOZ_OVERRIDE { return !!gl(); } |
michael@0 | 35 | |
michael@0 | 36 | virtual gfx::IntSize GetSize() const MOZ_OVERRIDE; |
michael@0 | 37 | |
michael@0 | 38 | virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE; |
michael@0 | 39 | |
michael@0 | 40 | virtual GLenum GetTextureTarget() const { return LOCAL_GL_TEXTURE_RECTANGLE_ARB; } |
michael@0 | 41 | |
michael@0 | 42 | virtual GLenum GetWrapMode() const MOZ_OVERRIDE { return LOCAL_GL_CLAMP_TO_EDGE; } |
michael@0 | 43 | |
michael@0 | 44 | // MacIOSurfaceTextureSourceOGL doesn't own any gl texture |
michael@0 | 45 | virtual void DeallocateDeviceData() {} |
michael@0 | 46 | |
michael@0 | 47 | virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE; |
michael@0 | 48 | |
michael@0 | 49 | gl::GLContext* gl() const; |
michael@0 | 50 | |
michael@0 | 51 | protected: |
michael@0 | 52 | CompositorOGL* mCompositor; |
michael@0 | 53 | RefPtr<MacIOSurface> mSurface; |
michael@0 | 54 | }; |
michael@0 | 55 | |
michael@0 | 56 | /** |
michael@0 | 57 | * A TextureHost for shared MacIOSurface |
michael@0 | 58 | * |
michael@0 | 59 | * Most of the logic actually happens in MacIOSurfaceTextureSourceOGL. |
michael@0 | 60 | */ |
michael@0 | 61 | class MacIOSurfaceTextureHostOGL : public TextureHost |
michael@0 | 62 | { |
michael@0 | 63 | public: |
michael@0 | 64 | MacIOSurfaceTextureHostOGL(TextureFlags aFlags, |
michael@0 | 65 | const SurfaceDescriptorMacIOSurface& aDescriptor); |
michael@0 | 66 | |
michael@0 | 67 | // SharedTextureHostOGL doesn't own any GL texture |
michael@0 | 68 | virtual void DeallocateDeviceData() MOZ_OVERRIDE {} |
michael@0 | 69 | |
michael@0 | 70 | virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE; |
michael@0 | 71 | |
michael@0 | 72 | virtual bool Lock() MOZ_OVERRIDE; |
michael@0 | 73 | |
michael@0 | 74 | virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE; |
michael@0 | 75 | |
michael@0 | 76 | virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE |
michael@0 | 77 | { |
michael@0 | 78 | return mTextureSource; |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE |
michael@0 | 82 | { |
michael@0 | 83 | return nullptr; // XXX - implement this (for MOZ_DUMP_PAINTING) |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | gl::GLContext* gl() const; |
michael@0 | 87 | |
michael@0 | 88 | virtual gfx::IntSize GetSize() const MOZ_OVERRIDE; |
michael@0 | 89 | |
michael@0 | 90 | #ifdef MOZ_LAYERS_HAVE_LOG |
michael@0 | 91 | virtual const char* Name() { return "MacIOSurfaceTextureHostOGL"; } |
michael@0 | 92 | #endif |
michael@0 | 93 | |
michael@0 | 94 | protected: |
michael@0 | 95 | CompositorOGL* mCompositor; |
michael@0 | 96 | RefPtr<MacIOSurfaceTextureSourceOGL> mTextureSource; |
michael@0 | 97 | RefPtr<MacIOSurface> mSurface; |
michael@0 | 98 | }; |
michael@0 | 99 | |
michael@0 | 100 | } |
michael@0 | 101 | } |
michael@0 | 102 | |
michael@0 | 103 | #endif // MOZILLA_GFX_MACIOSURFACETEXTUREHOSTOGL_H |