Hash :
3dddccff
Author :
Date :
2017-11-14T16:44:36
Support RGB gl-tex-external stream consumers for StreamProducerNV12. This makes it relatively simple to sample from a D3D11Texture of arbitrary format. From: https://bugzilla.mozilla.org/show_bug.cgi?id=1322746 BUG=angleproject:2233 TEST=angle_end2end_tests Change-Id: I10cd3043b5cb0c5d36dd613467ba6c0ceadf41af Reviewed-on: https://chromium-review.googlesource.com/758042 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
//
// 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,
D3D11Texture,
};
// 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 createProducerD3D11Texture(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 validateD3D11Texture(void *texture, const AttributeMap &attributes) const;
Error postD3D11Texture(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_