Edit

kc3-lang/angle/src/libANGLE/Stream.h

Branch :

  • Show log

    Commit

  • Author : Jamie Madill
    Date : 2017-06-20 12:57:39
    Hash : 4928b7ca
    Message : Proliferate gl::Context everywhere. This gives the D3D back-end access to the GL state almost anywhere. This uses the onDestroy hook for Textures to push errors up from destructors, although they still don't quite make it to the Context. There are places, such as in EGL object (Context/Surface) destruction, where we end up calling through to GL implementation internals without having access to a gl::Context. We handle this via a proxy Context to a Display, basically a null context, that has access to impl-side state like the Renderer pointer if necessary. It does not have access to the normal GL state. Also Pass gl::Context to RefCountObject::release(). Since we're using destroy() methods now, we should not ever call the destructor directly. BUG=angleproject:1156 Change-Id: Ie4c32ad6bf6caaff0289901f30b5c6bafa2ce259 Reviewed-on: https://chromium-review.googlesource.com/529707 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>

  • src/libANGLE/Stream.h
  • //
    // Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
    // Use of this source code is governed by a BSD-style license that can be
    // found in the LICENSE file.
    //
    
    // Stream.h: Defines the egl::Stream class, representing the stream
    // where frames are streamed in. Implements EGLStreanKHR.
    
    #ifndef LIBANGLE_STREAM_H_
    #define LIBANGLE_STREAM_H_
    
    #include <array>
    
    #include <EGL/egl.h>
    #include <EGL/eglext.h>
    
    #include "common/angleutils.h"
    #include "libANGLE/AttributeMap.h"
    
    namespace rx
    {
    class StreamProducerImpl;
    }
    
    namespace gl
    {
    class Context;
    class Texture;
    }
    
    namespace egl
    {
    class Display;
    class Error;
    class Thread;
    
    class Stream final : angle::NonCopyable
    {
      public:
        Stream(Display *display, const AttributeMap &attribs);
        ~Stream();
    
        enum class ConsumerType
        {
            NoConsumer,
            GLTextureRGB,
            GLTextureYUV,
        };
    
        enum class ProducerType
        {
            NoProducer,
            D3D11TextureNV12,
        };
    
        // A GL texture interpretation of a part of a producer frame. For use with GL texture consumers
        struct GLTextureDescription
        {
            unsigned int width;
            unsigned int height;
            unsigned int internalFormat;
            unsigned int mipLevels;
        };
    
        EGLenum getState() const;
    
        void setConsumerLatency(EGLint latency);
        EGLint getConsumerLatency() const;
    
        EGLuint64KHR getProducerFrame() const;
        EGLuint64KHR getConsumerFrame() const;
    
        void setConsumerAcquireTimeout(EGLint timeout);
        EGLint getConsumerAcquireTimeout() const;
    
        ConsumerType getConsumerType() const;
        ProducerType getProducerType() const;
    
        EGLint getPlaneCount() const;
    
        rx::StreamProducerImpl *getImplementation();
    
        // Consumer creation methods
        Error createConsumerGLTextureExternal(const AttributeMap &attributes, gl::Context *context);
    
        // Producer creation methods
        Error createProducerD3D11TextureNV12(const AttributeMap &attributes);
    
        // Consumer methods
        Error consumerAcquire(const gl::Context *context);
        Error consumerRelease(const gl::Context *context);
    
        // Some consumers are bound to GL contexts. This validates that a given context is bound to the
        // stream's consumer
        bool isConsumerBoundToContext(const gl::Context *context) const;
    
        // Producer methods
        Error validateD3D11NV12Texture(void *texture) const;
        Error postD3D11NV12Texture(void *texture, const AttributeMap &attributes);
    
      private:
        // Associated display
        Display *mDisplay;
    
        // Producer Implementation
        rx::StreamProducerImpl *mProducerImplementation;
    
        // Associated GL context. Note that this is a weak pointer used for validation purposes only,
        // and should never be arbitrarily dereferenced without knowing the context still exists as it
        // can become dangling at any time.
        gl::Context *mContext;
    
        // EGL defined attributes
        EGLint mState;
        EGLuint64KHR mProducerFrame;
        EGLuint64KHR mConsumerFrame;
        EGLint mConsumerLatency;
    
        // EGL gltexture consumer attributes
        EGLint mConsumerAcquireTimeout;
    
        // EGL gltexture yuv consumer attributes
        EGLint mPlaneCount;
        struct PlaneTexture
        {
            EGLint textureUnit;
            gl::Texture *texture;
        };
        // Texture units and textures for all the planes
        std::array<PlaneTexture, 3> mPlanes;
    
        // Consumer and producer types
        ConsumerType mConsumerType;
        ProducerType mProducerType;
    
        // ANGLE-only method, used internally
        friend class gl::Texture;
        void releaseTextures();
    };
    }  // namespace egl
    
    #endif  // LIBANGLE_STREAM_H_