gfx/gl/SharedSurfaceANGLE.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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/. */
     6 #ifndef SHARED_SURFACE_ANGLE_H_
     7 #define SHARED_SURFACE_ANGLE_H_
     9 #include "SharedSurfaceGL.h"
    10 #include "SurfaceFactory.h"
    11 #include "GLLibraryEGL.h"
    12 #include "SurfaceTypes.h"
    14 #include <windows.h>
    15 #include <d3d10_1.h>
    17 namespace mozilla {
    18 namespace gl {
    20 class GLContext;
    22 class SharedSurface_ANGLEShareHandle
    23     : public SharedSurface_GL
    24 {
    25 public:
    26     static SharedSurface_ANGLEShareHandle* Create(GLContext* gl, ID3D10Device1* d3d,
    27                                                   EGLContext context, EGLConfig config,
    28                                                   const gfx::IntSize& size,
    29                                                   bool hasAlpha);
    31     static SharedSurface_ANGLEShareHandle* Cast(SharedSurface* surf) {
    32         MOZ_ASSERT(surf->Type() == SharedSurfaceType::EGLSurfaceANGLE);
    34         return (SharedSurface_ANGLEShareHandle*)surf;
    35     }
    37 protected:
    38     GLLibraryEGL* const mEGL;
    39     const EGLContext mContext;
    40     const EGLSurface mPBuffer;
    41     nsRefPtr<ID3D10Texture2D> mTexture;
    42     nsRefPtr<ID3D10ShaderResourceView> mSRV;
    44     SharedSurface_ANGLEShareHandle(GLContext* gl,
    45                                    GLLibraryEGL* egl,
    46                                    const gfx::IntSize& size,
    47                                    bool hasAlpha,
    48                                    EGLContext context,
    49                                    EGLSurface pbuffer,
    50                                    ID3D10Texture2D* texture,
    51                                    ID3D10ShaderResourceView* srv)
    52         : SharedSurface_GL(SharedSurfaceType::EGLSurfaceANGLE,
    53                            AttachmentType::Screen,
    54                            gl,
    55                            size,
    56                            hasAlpha)
    57         , mEGL(egl)
    58         , mContext(context)
    59         , mPBuffer(pbuffer)
    60         , mTexture(texture)
    61         , mSRV(srv)
    62     {}
    64     EGLDisplay Display();
    66 public:
    67     virtual ~SharedSurface_ANGLEShareHandle();
    69     virtual void LockProdImpl() MOZ_OVERRIDE;
    70     virtual void UnlockProdImpl() MOZ_OVERRIDE;
    72     virtual void Fence() MOZ_OVERRIDE;
    73     virtual bool WaitSync() MOZ_OVERRIDE;
    75     // Implementation-specific functions below:
    76     ID3D10ShaderResourceView* GetSRV() {
    77         return mSRV;
    78     }
    79 };
    83 class SurfaceFactory_ANGLEShareHandle
    84     : public SurfaceFactory_GL
    85 {
    86 protected:
    87     GLContext* const mProdGL;
    88     GLLibraryEGL* const mEGL;
    89     nsRefPtr<ID3D10Device1> mConsD3D;
    90     EGLContext mContext;
    91     EGLConfig mConfig;
    93 public:
    94     static SurfaceFactory_ANGLEShareHandle* Create(GLContext* gl,
    95                                                    ID3D10Device1* d3d,
    96                                                    const SurfaceCaps& caps);
    98 protected:
    99     SurfaceFactory_ANGLEShareHandle(GLContext* gl,
   100                                     GLLibraryEGL* egl,
   101                                     ID3D10Device1* d3d,
   102                                     const SurfaceCaps& caps);
   104     virtual SharedSurface* CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE {
   105         bool hasAlpha = mReadCaps.alpha;
   106         return SharedSurface_ANGLEShareHandle::Create(mProdGL, mConsD3D,
   107                                                       mContext, mConfig,
   108                                                       size, hasAlpha);
   109     }
   110 };
   112 } /* namespace gfx */
   113 } /* namespace mozilla */
   115 #endif /* SHARED_SURFACE_ANGLE_H_ */

mercurial