зеркало из https://github.com/mozilla/gecko-dev.git
Bug 975384 - Add pointer check to GrallocTextureHostOGL r=nical
This commit is contained in:
Родитель
4aecb56891
Коммит
35e512d271
|
@ -115,6 +115,9 @@ void GrallocTextureSourceOGL::BindTexture(GLenum aTextureUnit)
|
|||
* texture using fEGLImageTargetTexture2D.
|
||||
*/
|
||||
MOZ_ASSERT(gl());
|
||||
if (!IsValid()) {
|
||||
return;
|
||||
}
|
||||
gl()->MakeCurrent();
|
||||
|
||||
GLuint tex = GetGLTexture();
|
||||
|
@ -155,6 +158,9 @@ GLenum
|
|||
GrallocTextureSourceOGL::GetTextureTarget() const
|
||||
{
|
||||
MOZ_ASSERT(mGraphicBuffer.get());
|
||||
if (!mGraphicBuffer.get()) {
|
||||
return LOCAL_GL_TEXTURE_EXTERNAL;
|
||||
}
|
||||
return TextureTargetForAndroidPixelFormat(mGraphicBuffer->getPixelFormat());
|
||||
}
|
||||
|
||||
|
@ -172,7 +178,7 @@ GrallocTextureSourceOGL::GetFormat() const {
|
|||
void
|
||||
GrallocTextureSourceOGL::SetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData)
|
||||
{
|
||||
if (!aBackendData) {
|
||||
if (!aBackendData || !mGraphicBuffer.get()) {
|
||||
mCompositableBackendData = nullptr;
|
||||
DeallocateDeviceData();
|
||||
return;
|
||||
|
@ -239,17 +245,23 @@ GrallocTextureHostOGL::GrallocTextureHostOGL(TextureFlags aFlags,
|
|||
const NewSurfaceDescriptorGralloc& aDescriptor)
|
||||
: TextureHost(aFlags)
|
||||
{
|
||||
android::GraphicBuffer* graphicBuffer = nullptr;
|
||||
gfx::SurfaceFormat format = gfx::SurfaceFormat::UNKNOWN;
|
||||
|
||||
mSize = aDescriptor.size();
|
||||
mGrallocActor =
|
||||
static_cast<GrallocBufferActor*>(aDescriptor.bufferParent());
|
||||
|
||||
mGrallocActor->AddTextureHost(this);
|
||||
if (mGrallocActor) {
|
||||
mGrallocActor->AddTextureHost(this);
|
||||
graphicBuffer = mGrallocActor->GetGraphicBuffer();
|
||||
}
|
||||
|
||||
android::GraphicBuffer* graphicBuffer = mGrallocActor->GetGraphicBuffer();
|
||||
|
||||
mSize = aDescriptor.size();
|
||||
gfx::SurfaceFormat format =
|
||||
SurfaceFormatForAndroidPixelFormat(graphicBuffer->getPixelFormat(),
|
||||
aFlags & TEXTURE_RB_SWAPPED);
|
||||
if (graphicBuffer) {
|
||||
format =
|
||||
SurfaceFormatForAndroidPixelFormat(graphicBuffer->getPixelFormat(),
|
||||
aFlags & TEXTURE_RB_SWAPPED);
|
||||
}
|
||||
mTextureSource = new GrallocTextureSourceOGL(nullptr,
|
||||
graphicBuffer,
|
||||
format);
|
||||
|
@ -348,6 +360,9 @@ GrallocTextureHostOGL::GetAsSurface() {
|
|||
TemporaryRef<gfx::DataSourceSurface>
|
||||
GrallocTextureSourceOGL::GetAsSurface() {
|
||||
MOZ_ASSERT(gl());
|
||||
if (!IsValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
gl()->MakeCurrent();
|
||||
|
||||
GLuint tex = GetGLTexture();
|
||||
|
|
Загрузка…
Ссылка в новой задаче