gfx/gl/SharedSurfaceIO.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/gl/SharedSurfaceIO.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,79 @@
     1.4 +/* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef SHARED_SURFACEIO_H_
    1.10 +#define SHARED_SURFACEIO_H_
    1.11 +
    1.12 +#include "gfxImageSurface.h"
    1.13 +#include "SharedSurfaceGL.h"
    1.14 +#include "mozilla/RefPtr.h"
    1.15 +
    1.16 +class MacIOSurface;
    1.17 +
    1.18 +namespace mozilla {
    1.19 +namespace gl {
    1.20 +
    1.21 +class SharedSurface_IOSurface : public SharedSurface_GL
    1.22 +{
    1.23 +public:
    1.24 +    static SharedSurface_IOSurface* Create(MacIOSurface* surface, GLContext *gl, bool hasAlpha);
    1.25 +
    1.26 +    ~SharedSurface_IOSurface();
    1.27 +
    1.28 +    virtual void LockProdImpl() MOZ_OVERRIDE { }
    1.29 +    virtual void UnlockProdImpl() MOZ_OVERRIDE { }
    1.30 +
    1.31 +    virtual void Fence() MOZ_OVERRIDE;
    1.32 +    virtual bool WaitSync() MOZ_OVERRIDE { return true; }
    1.33 +
    1.34 +    virtual bool ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
    1.35 +                            GLenum format, GLenum type, GLvoid *pixels) MOZ_OVERRIDE;
    1.36 +
    1.37 +    virtual GLuint ProdTexture() MOZ_OVERRIDE {
    1.38 +        return mProdTex;
    1.39 +    }
    1.40 +
    1.41 +    virtual GLenum ProdTextureTarget() const MOZ_OVERRIDE {
    1.42 +        return LOCAL_GL_TEXTURE_RECTANGLE_ARB;
    1.43 +    }
    1.44 +
    1.45 +    static SharedSurface_IOSurface* Cast(SharedSurface *surf) {
    1.46 +        MOZ_ASSERT(surf->Type() == SharedSurfaceType::IOSurface);
    1.47 +        return static_cast<SharedSurface_IOSurface*>(surf);
    1.48 +    }
    1.49 +
    1.50 +    GLuint ConsTexture(GLContext* consGL);
    1.51 +
    1.52 +    GLenum ConsTextureTarget() const {
    1.53 +        return LOCAL_GL_TEXTURE_RECTANGLE_ARB;
    1.54 +    }
    1.55 +
    1.56 +private:
    1.57 +    SharedSurface_IOSurface(MacIOSurface* surface, GLContext* gl, const gfx::IntSize& size, bool hasAlpha);
    1.58 +
    1.59 +    RefPtr<MacIOSurface> mSurface;
    1.60 +    nsRefPtr<gfxImageSurface> mImageSurface;
    1.61 +    GLuint mProdTex;
    1.62 +    const GLContext* mCurConsGL;
    1.63 +    GLuint mConsTex;
    1.64 +};
    1.65 +
    1.66 +class SurfaceFactory_IOSurface : public SurfaceFactory_GL
    1.67 +{
    1.68 +public:
    1.69 +    SurfaceFactory_IOSurface(GLContext* gl,
    1.70 +                             const SurfaceCaps& caps)
    1.71 +        : SurfaceFactory_GL(gl, SharedSurfaceType::IOSurface, caps)
    1.72 +    {
    1.73 +    }
    1.74 +
    1.75 +protected:
    1.76 +    virtual SharedSurface* CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE;
    1.77 +};
    1.78 +
    1.79 +} /* namespace gfx */
    1.80 +} /* namespace mozilla */
    1.81 +
    1.82 +#endif /* SHARED_SURFACEIO_H_ */

mercurial