// // Copyright 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.cpp: Implements the egl::Stream class, representing the stream // where frames are streamed in. Implements EGLStreanKHR.
constauto &glState = context->getState();
EGLenum bufferType = attributes.getAsInt(EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER); if (bufferType == EGL_RGB_BUFFER)
{
mPlanes[0].texture = glState.getTargetTexture(gl::TextureType::External);
ASSERT(mPlanes[0].texture != nullptr);
mPlanes[0].texture->bindStream(this);
mConsumerType = ConsumerType::GLTextureRGB;
mPlaneCount = 1;
} else
{
mPlaneCount = attributes.getAsInt(EGL_YUV_NUMBER_OF_PLANES_EXT, 2);
ASSERT(mPlaneCount <= 3); for (EGLint i = 0; i < mPlaneCount; i++)
{ // Fetch all the textures
mPlanes[i].textureUnit = attributes.getAsInt(EGL_YUV_PLANE0_TEXTURE_UNIT_NV + i, -1); if (mPlanes[i].textureUnit != EGL_NONE)
{
mPlanes[i].texture =
glState.getSamplerTexture(mPlanes[i].textureUnit, gl::TextureType::External);
ASSERT(mPlanes[i].texture != nullptr);
}
}
// Bind them to the stream for (EGLint i = 0; i < mPlaneCount; i++)
{ if (mPlanes[i].textureUnit != EGL_NONE)
{
mPlanes[i].texture->bindStream(this);
}
}
mConsumerType = ConsumerType::GLTextureYUV;
}
// Called when the consumer of this stream starts using the stream
Error Stream::consumerAcquire(const gl::Context *context)
{
ASSERT(mState == EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR ||
mState == EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR);
ASSERT(mConsumerType == ConsumerType::GLTextureRGB ||
mConsumerType == ConsumerType::GLTextureYUV);
ASSERT(mProducerType == ProducerType::D3D11Texture);
// Bind the planes to the gl textures for (int i = 0; i < mPlaneCount; i++)
{ if (mPlanes[i].texture != nullptr)
{
ANGLE_TRY(ResultToEGL(mPlanes[i].texture->acquireImageFromStream(
context, mProducerImplementation->getGLFrameDescription(i))));
}
}
// Release the images for (int i = 0; i < mPlaneCount; i++)
{ if (mPlanes[i].texture != nullptr)
{
ANGLE_TRY(ResultToEGL(mPlanes[i].texture->releaseImageFromStream(context)));
}
}
// This is called when a texture object associated with this stream is destroyed. Even if multiple // textures are bound, one being destroyed invalidates the stream, so all the remaining textures // will be released and the stream will be invalidated. void Stream::releaseTextures()
{ for (auto &plane : mPlanes)
{ if (plane.texture != nullptr)
{
plane.texture->releaseStream();
plane.texture = nullptr;
}
}
mConsumerType = ConsumerType::NoConsumer;
mProducerType = ProducerType::NoProducer;
mState = EGL_STREAM_STATE_DISCONNECTED_KHR;
}
} // namespace egl
Messung V0.5
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.