gfx/gl/SharedSurfaceIO.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */
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 SHARED_SURFACEIO_H_
michael@0 7 #define SHARED_SURFACEIO_H_
michael@0 8
michael@0 9 #include "gfxImageSurface.h"
michael@0 10 #include "SharedSurfaceGL.h"
michael@0 11 #include "mozilla/RefPtr.h"
michael@0 12
michael@0 13 class MacIOSurface;
michael@0 14
michael@0 15 namespace mozilla {
michael@0 16 namespace gl {
michael@0 17
michael@0 18 class SharedSurface_IOSurface : public SharedSurface_GL
michael@0 19 {
michael@0 20 public:
michael@0 21 static SharedSurface_IOSurface* Create(MacIOSurface* surface, GLContext *gl, bool hasAlpha);
michael@0 22
michael@0 23 ~SharedSurface_IOSurface();
michael@0 24
michael@0 25 virtual void LockProdImpl() MOZ_OVERRIDE { }
michael@0 26 virtual void UnlockProdImpl() MOZ_OVERRIDE { }
michael@0 27
michael@0 28 virtual void Fence() MOZ_OVERRIDE;
michael@0 29 virtual bool WaitSync() MOZ_OVERRIDE { return true; }
michael@0 30
michael@0 31 virtual bool ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
michael@0 32 GLenum format, GLenum type, GLvoid *pixels) MOZ_OVERRIDE;
michael@0 33
michael@0 34 virtual GLuint ProdTexture() MOZ_OVERRIDE {
michael@0 35 return mProdTex;
michael@0 36 }
michael@0 37
michael@0 38 virtual GLenum ProdTextureTarget() const MOZ_OVERRIDE {
michael@0 39 return LOCAL_GL_TEXTURE_RECTANGLE_ARB;
michael@0 40 }
michael@0 41
michael@0 42 static SharedSurface_IOSurface* Cast(SharedSurface *surf) {
michael@0 43 MOZ_ASSERT(surf->Type() == SharedSurfaceType::IOSurface);
michael@0 44 return static_cast<SharedSurface_IOSurface*>(surf);
michael@0 45 }
michael@0 46
michael@0 47 GLuint ConsTexture(GLContext* consGL);
michael@0 48
michael@0 49 GLenum ConsTextureTarget() const {
michael@0 50 return LOCAL_GL_TEXTURE_RECTANGLE_ARB;
michael@0 51 }
michael@0 52
michael@0 53 private:
michael@0 54 SharedSurface_IOSurface(MacIOSurface* surface, GLContext* gl, const gfx::IntSize& size, bool hasAlpha);
michael@0 55
michael@0 56 RefPtr<MacIOSurface> mSurface;
michael@0 57 nsRefPtr<gfxImageSurface> mImageSurface;
michael@0 58 GLuint mProdTex;
michael@0 59 const GLContext* mCurConsGL;
michael@0 60 GLuint mConsTex;
michael@0 61 };
michael@0 62
michael@0 63 class SurfaceFactory_IOSurface : public SurfaceFactory_GL
michael@0 64 {
michael@0 65 public:
michael@0 66 SurfaceFactory_IOSurface(GLContext* gl,
michael@0 67 const SurfaceCaps& caps)
michael@0 68 : SurfaceFactory_GL(gl, SharedSurfaceType::IOSurface, caps)
michael@0 69 {
michael@0 70 }
michael@0 71
michael@0 72 protected:
michael@0 73 virtual SharedSurface* CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE;
michael@0 74 };
michael@0 75
michael@0 76 } /* namespace gfx */
michael@0 77 } /* namespace mozilla */
michael@0 78
michael@0 79 #endif /* SHARED_SURFACEIO_H_ */

mercurial