gfx/gl/SharedSurface.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.

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 /* SharedSurface abstracts an actual surface (can be a GL texture, but
michael@0 7 * not necessarily) that handles sharing.
michael@0 8 * Its specializations are:
michael@0 9 * SharedSurface_Basic (client-side bitmap, does readback)
michael@0 10 * SharedSurface_GLTexture
michael@0 11 * SharedSurface_EGLImage
michael@0 12 * SharedSurface_ANGLEShareHandle
michael@0 13 */
michael@0 14
michael@0 15 #ifndef SHARED_SURFACE_H_
michael@0 16 #define SHARED_SURFACE_H_
michael@0 17
michael@0 18 #include <stdint.h>
michael@0 19 #include "mozilla/Attributes.h"
michael@0 20 #include "GLDefs.h"
michael@0 21 #include "mozilla/gfx/Point.h"
michael@0 22 #include "SurfaceTypes.h"
michael@0 23
michael@0 24 namespace mozilla {
michael@0 25 namespace gfx {
michael@0 26
michael@0 27 class SurfaceFactory;
michael@0 28
michael@0 29 class SharedSurface
michael@0 30 {
michael@0 31 protected:
michael@0 32 const SharedSurfaceType mType;
michael@0 33 const APITypeT mAPI;
michael@0 34 const AttachmentType mAttachType;
michael@0 35 const gfx::IntSize mSize;
michael@0 36 const bool mHasAlpha;
michael@0 37 bool mIsLocked;
michael@0 38
michael@0 39 SharedSurface(SharedSurfaceType type,
michael@0 40 APITypeT api,
michael@0 41 AttachmentType attachType,
michael@0 42 const gfx::IntSize& size,
michael@0 43 bool hasAlpha)
michael@0 44 : mType(type)
michael@0 45 , mAPI(api)
michael@0 46 , mAttachType(attachType)
michael@0 47 , mSize(size)
michael@0 48 , mHasAlpha(hasAlpha)
michael@0 49 , mIsLocked(false)
michael@0 50 {
michael@0 51 }
michael@0 52
michael@0 53 public:
michael@0 54 virtual ~SharedSurface() {
michael@0 55 }
michael@0 56
michael@0 57 static void Copy(SharedSurface* src, SharedSurface* dest,
michael@0 58 SurfaceFactory* factory);
michael@0 59
michael@0 60 // This locks the SharedSurface as the production buffer for the context.
michael@0 61 // This is needed by backends which use PBuffers and/or EGLSurfaces.
michael@0 62 virtual void LockProd() {
michael@0 63 MOZ_ASSERT(!mIsLocked);
michael@0 64 LockProdImpl();
michael@0 65 mIsLocked = true;
michael@0 66 }
michael@0 67
michael@0 68 // Unlocking is harmless if we're already unlocked.
michael@0 69 virtual void UnlockProd() {
michael@0 70 if (!mIsLocked)
michael@0 71 return;
michael@0 72
michael@0 73 UnlockProdImpl();
michael@0 74 mIsLocked = false;
michael@0 75 }
michael@0 76
michael@0 77 virtual void LockProdImpl() = 0;
michael@0 78 virtual void UnlockProdImpl() = 0;
michael@0 79
michael@0 80 virtual void Fence() = 0;
michael@0 81 virtual bool WaitSync() = 0;
michael@0 82
michael@0 83
michael@0 84 SharedSurfaceType Type() const {
michael@0 85 return mType;
michael@0 86 }
michael@0 87
michael@0 88 APITypeT APIType() const {
michael@0 89 return mAPI;
michael@0 90 }
michael@0 91
michael@0 92 AttachmentType AttachType() const {
michael@0 93 return mAttachType;
michael@0 94 }
michael@0 95
michael@0 96 const gfx::IntSize& Size() const {
michael@0 97 return mSize;
michael@0 98 }
michael@0 99
michael@0 100 bool HasAlpha() const {
michael@0 101 return mHasAlpha;
michael@0 102 }
michael@0 103 };
michael@0 104
michael@0 105 } /* namespace gfx */
michael@0 106 } /* namespace mozilla */
michael@0 107
michael@0 108 #endif /* SHARED_SURFACE_H_ */

mercurial