gl_deschedule_unittest.cc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2016 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include <GLES2/gl2.h>
  5. #include <GLES2/gl2ext.h>
  6. #include <GLES2/gl2extchromium.h>
  7. #include "gpu/command_buffer/tests/gl_manager.h"
  8. #include "gpu/command_buffer/tests/gl_test_utils.h"
  9. #include "testing/gtest/include/gtest/gtest.h"
  10. namespace gpu {
  11. class GLDescheduleTest : public testing::Test {
  12. protected:
  13. void SetUp() override {
  14. GLManager::Options options;
  15. gl1_.Initialize(options);
  16. }
  17. void TearDown() override {
  18. gl1_.Destroy();
  19. }
  20. GLManager gl1_;
  21. };
  22. TEST_F(GLDescheduleTest, Deschedule) {
  23. gl1_.MakeCurrent();
  24. GLuint tex = 0;
  25. glGenTextures(1, &tex);
  26. glBindTexture(GL_TEXTURE_2D, tex);
  27. glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
  28. nullptr);
  29. GLuint fbo = 0;
  30. glGenFramebuffers(1, &fbo);
  31. glBindFramebuffer(GL_FRAMEBUFFER, fbo);
  32. glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
  33. tex, 0);
  34. glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
  35. glClear(GL_COLOR_BUFFER_BIT);
  36. glDescheduleUntilFinishedCHROMIUM();
  37. glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
  38. glClear(GL_COLOR_BUFFER_BIT);
  39. glFlush();
  40. glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
  41. glClear(GL_COLOR_BUFFER_BIT);
  42. glFlush();
  43. uint32_t result;
  44. glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
  45. &result);
  46. EXPECT_EQ(0xFF00FF00u, result);
  47. }
  48. } // namespace gpu