Hash :
c408926f
Author :
Date :
2021-07-22T12:00:59
Revert "EGL: GLES: Implement GL_EXT_protected_textures" This reverts commit 6210a9b34a721df2c84cf69170ad9bf7ba40e4aa. Reason for revert: Suspected for breaking ANGLE->Chrome roller. Bug: angleproject:6204 Original change's description: > EGL: GLES: Implement GL_EXT_protected_textures > > Implement EGL_EXT_protected_content Images > Add protected member to Images and Textures > Add error when creating objects if not supported or > does't match native buffer > When creating siblings pass protected state > Add extension caps > Add Validation > Add GetTexParameter and SetTextparameter > Add protected to Texture and state > Expand tests for images and textures > > Test: angle_end2end_test --gtest_filter=EGLProtectedContentTest > > Bug: angleproject:3965 > Change-Id: I35a89b4e80bba6d9b6831c68e71630eef304dacb > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2802852 > Commit-Queue: Mohan Maiya <m.maiya@samsung.com> > Reviewed-by: Geoff Lang <geofflang@chromium.org> > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Bug: angleproject:3965 Change-Id: Ia3ef260a17097b474189ccad5b235a9db99ee00b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3043889 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
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 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248
//
// Copyright 2021 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.
//
// EGLProtectedContentTest.cpp:
// EGL extension EGL_EXT_protected_content
//
#include <gtest/gtest.h>
#include <chrono>
#include <iostream>
#include <thread>
#include "test_utils/ANGLETest.h"
#include "util/EGLWindow.h"
#include "util/OSWindow.h"
using namespace std::chrono_literals;
using namespace angle;
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EGLProtectedContentTest);
class EGLProtectedContentTest : public ANGLETest
{
public:
EGLProtectedContentTest() : mDisplay(EGL_NO_DISPLAY) {}
void testSetUp() override
{
EGLint dispattrs[] = {EGL_PLATFORM_ANGLE_TYPE_ANGLE, GetParam().getRenderer(), EGL_NONE};
mDisplay = eglGetPlatformDisplayEXT(
EGL_PLATFORM_ANGLE_ANGLE, reinterpret_cast<void *>(EGL_DEFAULT_DISPLAY), dispattrs);
EXPECT_TRUE(mDisplay != EGL_NO_DISPLAY);
EXPECT_EGL_TRUE(eglInitialize(mDisplay, nullptr, nullptr));
mMajorVersion = GetParam().majorVersion;
}
void testTearDown() override
{
if (mDisplay != EGL_NO_DISPLAY)
{
eglTerminate(mDisplay);
eglReleaseThread();
mDisplay = EGL_NO_DISPLAY;
}
ASSERT_EGL_SUCCESS() << "Error during test TearDown";
}
bool chooseConfig(EGLConfig *config)
{
EGLint clientVersion = mMajorVersion == 3 ? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT;
EGLint attribs[] = {EGL_RED_SIZE,
8,
EGL_GREEN_SIZE,
8,
EGL_BLUE_SIZE,
8,
EGL_ALPHA_SIZE,
8,
EGL_RENDERABLE_TYPE,
clientVersion,
EGL_SURFACE_TYPE,
(EGL_PBUFFER_BIT | EGL_WINDOW_BIT),
EGL_NONE};
EGLint count = 0;
bool result = eglChooseConfig(mDisplay, attribs, config, 1, &count);
EXPECT_EGL_TRUE(result);
EXPECT_EGL_TRUE(count > 0);
return result;
}
bool createContext(EGLBoolean isProtected, EGLConfig config, EGLContext *context)
{
bool result = false;
EGLint attribsProtected[] = {EGL_CONTEXT_MAJOR_VERSION, mMajorVersion,
EGL_PROTECTED_CONTENT_EXT, EGL_TRUE, EGL_NONE};
EGLint attribsUnProtected[] = {EGL_CONTEXT_MAJOR_VERSION, mMajorVersion, EGL_NONE};
*context = eglCreateContext(mDisplay, config, nullptr,
(isProtected ? attribsProtected : attribsUnProtected));
result = (*context != EGL_NO_CONTEXT);
EXPECT_TRUE(result);
return result;
}
bool createPbufferSurface(EGLBoolean isProtected, EGLConfig config, EGLSurface *surface)
{
bool result = false;
EGLint attribsProtected[] = {
EGL_WIDTH, kWidth, EGL_HEIGHT, kHeight, EGL_PROTECTED_CONTENT_EXT, EGL_TRUE, EGL_NONE};
EGLint attribsUnProtected[] = {EGL_WIDTH, kWidth, EGL_HEIGHT, kHeight, EGL_NONE};
*surface = eglCreatePbufferSurface(mDisplay, config,
(isProtected ? attribsProtected : attribsUnProtected));
result = (*surface != EGL_NO_SURFACE);
EXPECT_TRUE(result);
return result;
}
bool createWindowSurface(EGLBoolean isProtected,
EGLConfig config,
EGLNativeWindowType win,
EGLSurface *surface)
{
bool result = false;
EGLint attribsProtected[] = {EGL_PROTECTED_CONTENT_EXT, EGL_TRUE, EGL_NONE};
EGLint attribsUnProtected[] = {EGL_NONE};
*surface = eglCreateWindowSurface(mDisplay, config, win,
(isProtected ? attribsProtected : attribsUnProtected));
result = (*surface != EGL_NO_SURFACE);
EXPECT_TRUE(result);
return result;
}
void PbufferTest(bool isProtectedContext, bool isProtectedSurface);
void WindowTest(bool isProtectedContext, bool isProtectedSurface);
EGLDisplay mDisplay = EGL_NO_DISPLAY;
EGLint mMajorVersion = 0;
static const EGLint kWidth = 16;
static const EGLint kHeight = 16;
};
void EGLProtectedContentTest::PbufferTest(bool isProtectedContext, bool isProtectedSurface)
{
if (isProtectedContext || isProtectedSurface)
{
ANGLE_SKIP_TEST_IF(!IsEGLDisplayExtensionEnabled(mDisplay, "EGL_EXT_protected_content"));
}
EGLConfig config = EGL_NO_CONFIG_KHR;
EXPECT_TRUE(chooseConfig(&config));
EGLContext context = EGL_NO_CONTEXT;
EXPECT_TRUE(createContext(isProtectedContext, config, &context));
ASSERT_EGL_SUCCESS() << "eglCreateContext failed.";
EGLSurface pBufferSurface = EGL_NO_SURFACE;
EXPECT_TRUE(createPbufferSurface(isProtectedSurface, config, &pBufferSurface));
ASSERT_EGL_SUCCESS() << "eglCreatePbufferSurface failed.";
EXPECT_TRUE(eglMakeCurrent(mDisplay, pBufferSurface, pBufferSurface, context));
ASSERT_EGL_SUCCESS() << "eglMakeCurrent failed.";
glClearColor(1.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glFinish();
ASSERT_GL_NO_ERROR() << "glFinish failed";
EXPECT_TRUE(eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, context));
ASSERT_EGL_SUCCESS() << "eglMakeCurrent - uncurrent failed.";
eglDestroySurface(mDisplay, pBufferSurface);
pBufferSurface = EGL_NO_SURFACE;
eglDestroyContext(mDisplay, context);
context = EGL_NO_CONTEXT;
}
// Unprotected context with Unprotected PbufferSurface
TEST_P(EGLProtectedContentTest, UnprotectedContextWithUnprotectedPbufferSurface)
{
PbufferTest(false, false);
}
void EGLProtectedContentTest::WindowTest(bool isProtectedContext, bool isProtectedSurface)
{
if (isProtectedContext || isProtectedSurface)
{
ANGLE_SKIP_TEST_IF(!IsEGLDisplayExtensionEnabled(mDisplay, "EGL_EXT_protected_content"));
}
EGLConfig config = EGL_NO_CONFIG_KHR;
EXPECT_TRUE(chooseConfig(&config));
EGLContext context = EGL_NO_CONTEXT;
EXPECT_TRUE(createContext(isProtectedContext, config, &context));
ASSERT_EGL_SUCCESS() << "eglCreateContext failed.";
OSWindow *osWindow = OSWindow::New();
osWindow->initialize("ProtectedContentTest", kWidth, kHeight);
EGLSurface windowSurface = EGL_NO_SURFACE;
EGLBoolean createWinSurfaceResult = createWindowSurface(
isProtectedSurface, config, osWindow->getNativeWindow(), &windowSurface);
EXPECT_TRUE(createWinSurfaceResult);
ASSERT_EGL_SUCCESS() << "eglCreateWindowSurface failed.";
EXPECT_TRUE(eglMakeCurrent(mDisplay, windowSurface, windowSurface, context));
ASSERT_EGL_SUCCESS() << "eglMakeCurrent failed.";
// Red
glClearColor(1.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
ASSERT_GL_NO_ERROR() << "glClear failed";
eglSwapBuffers(mDisplay, windowSurface);
ASSERT_EGL_SUCCESS() << "eglSwapBuffers failed.";
std::this_thread::sleep_for(1s);
// Green
glClearColor(0.0, 1.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
ASSERT_GL_NO_ERROR() << "glClear failed";
eglSwapBuffers(mDisplay, windowSurface);
ASSERT_EGL_SUCCESS() << "eglSwapBuffers failed.";
std::this_thread::sleep_for(1s);
// Blue
glClearColor(0.0, 0.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
ASSERT_GL_NO_ERROR() << "glClear failed";
eglSwapBuffers(mDisplay, windowSurface);
ASSERT_EGL_SUCCESS() << "eglSwapBuffers failed.";
std::this_thread::sleep_for(1s);
EXPECT_TRUE(eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, context));
ASSERT_EGL_SUCCESS() << "eglMakeCurrent - uncurrent failed.";
eglDestroySurface(mDisplay, windowSurface);
windowSurface = EGL_NO_SURFACE;
osWindow->destroy();
OSWindow::Delete(&osWindow);
eglDestroyContext(mDisplay, context);
context = EGL_NO_CONTEXT;
}
// Unprotected context with Unprotected WindowSurface
TEST_P(EGLProtectedContentTest, UnprotectedContextWithUnprotectedWindowSurface)
{
std::cout << "Operator should see RED, GREEN, BLUE on screen" << std::endl;
WindowTest(false, false);
}
// Protected context with Protected WindowSurface
TEST_P(EGLProtectedContentTest, ProtectedContextWithProtectedWindowSurface)
{
std::cout << "Operator should see RED, GREEN, BLUE on screen" << std::endl;
WindowTest(true, true);
}
ANGLE_INSTANTIATE_TEST(EGLProtectedContentTest,
WithNoFixture(ES2_VULKAN()),
WithNoFixture(ES3_VULKAN()));