gfx/gl/SharedSurfaceIO.h

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

mercurial