1 // Copyright 2013 The Flutter 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 5 #ifndef FLUTTER_TESTING_TEST_GL_SURFACE_H_ 6 #define FLUTTER_TESTING_TEST_GL_SURFACE_H_ 7 8 #include <cstdint> 9 10 #include "flutter/fml/macros.h" 11 #include "third_party/skia/include/gpu/GrContext.h" 12 13 namespace flutter { 14 namespace testing { 15 16 class TestGLSurface { 17 public: 18 TestGLSurface(); 19 20 ~TestGLSurface(); 21 22 SkISize GetSize() const; 23 24 bool MakeCurrent(); 25 26 bool ClearCurrent(); 27 28 bool Present(); 29 30 uint32_t GetFramebuffer() const; 31 32 bool MakeResourceCurrent(); 33 34 void* GetProcAddress(const char* name) const; 35 36 sk_sp<SkSurface> GetOnscreenSurface(); 37 38 sk_sp<GrContext> GetGrContext(); 39 40 sk_sp<GrContext> CreateGrContext(); 41 42 sk_sp<SkImage> GetRasterSurfaceSnapshot(); 43 44 private: 45 // Importing the EGL.h pulls in platform headers which are problematic 46 // (especially X11 which #defineds types like Bool). Any TUs importing 47 // this header then become susceptible to failures because of platform 48 // specific craziness. Don't expose EGL internals via this header. 49 using EGLDisplay = void*; 50 using EGLContext = void*; 51 using EGLSurface = void*; 52 53 EGLDisplay display_; 54 EGLContext onscreen_context_; 55 EGLContext offscreen_context_; 56 EGLSurface onscreen_surface_; 57 EGLSurface offscreen_surface_; 58 sk_sp<GrContext> context_; 59 60 FML_DISALLOW_COPY_AND_ASSIGN(TestGLSurface); 61 }; 62 63 } // namespace testing 64 } // namespace flutter 65 66 #endif // FLUTTER_TESTING_TEST_GL_SURFACE_H_ 67