Hash :
ba87b195
Author :
Date :
2022-09-01T13:38:17
OpenGL: Pass EGL_GL_COLORSPACE_KHR to OGL backend When we create NativeBufferImageSiblingAndroid, the attributes is lost, which caused a few AHB tests failed. This CL ensures we pass the EGL_GL_COLORSPACE_KHR attribute to NativeBufferImageSiblingAndroid and OpenGLES backend now passes. Bug: b/205995945 Change-Id: I5a0a9dc1d34dbc0167890791b397c3c83b0adef4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3869368 Auto-Submit: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yiwei Zhang <zzyiwei@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
//
// Copyright 2018 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.
//
// NativeBufferImageSiblingAndroid.cpp: Implements the NativeBufferImageSiblingAndroid class
#include "libANGLE/renderer/gl/egl/android/NativeBufferImageSiblingAndroid.h"
#include "common/android_util.h"
namespace rx
{
NativeBufferImageSiblingAndroid::NativeBufferImageSiblingAndroid(EGLClientBuffer buffer,
const egl::AttributeMap &attribs)
: mBuffer(buffer), mFormat(GL_NONE), mYUV(false), mColorSpace(EGL_GL_COLORSPACE_LINEAR_KHR)
{
if (attribs.contains(EGL_GL_COLORSPACE_KHR))
{
mColorSpace = attribs.getAsInt(EGL_GL_COLORSPACE_KHR);
}
}
NativeBufferImageSiblingAndroid::~NativeBufferImageSiblingAndroid() {}
egl::Error NativeBufferImageSiblingAndroid::initialize(const egl::Display *display)
{
int pixelFormat = 0;
uint64_t usage = 0;
angle::android::GetANativeWindowBufferProperties(
angle::android::ClientBufferToANativeWindowBuffer(mBuffer), &mSize.width, &mSize.height,
&mSize.depth, &pixelFormat, &usage);
mFormat = gl::Format(angle::android::NativePixelFormatToGLInternalFormat(pixelFormat));
mYUV = angle::android::NativePixelFormatIsYUV(pixelFormat);
mHasProtectedContent = false;
return egl::NoError();
}
gl::Format NativeBufferImageSiblingAndroid::getFormat() const
{
return mFormat;
}
bool NativeBufferImageSiblingAndroid::isRenderable(const gl::Context *context) const
{
return true;
}
bool NativeBufferImageSiblingAndroid::isTexturable(const gl::Context *context) const
{
return true;
}
bool NativeBufferImageSiblingAndroid::isYUV() const
{
return mYUV;
}
bool NativeBufferImageSiblingAndroid::hasProtectedContent() const
{
return mHasProtectedContent;
}
gl::Extents NativeBufferImageSiblingAndroid::getSize() const
{
return mSize;
}
size_t NativeBufferImageSiblingAndroid::getSamples() const
{
return 0;
}
EGLClientBuffer NativeBufferImageSiblingAndroid::getBuffer() const
{
return mBuffer;
}
void NativeBufferImageSiblingAndroid::getImageCreationAttributes(
std::vector<EGLint> *outAttributes) const
{
if (mColorSpace != EGL_GL_COLORSPACE_LINEAR_KHR)
{
outAttributes->push_back(EGL_GL_COLORSPACE_KHR);
outAttributes->push_back(mColorSpace);
}
}
} // namespace rx