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_SHELL_PLATFORM_ANDROID_ANDROID_CONTEXT_GL_H_ 6 #define FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_CONTEXT_GL_H_ 7 8 #include "flutter/fml/macros.h" 9 #include "flutter/fml/memory/ref_counted.h" 10 #include "flutter/fml/memory/ref_ptr.h" 11 #include "flutter/shell/common/platform_view.h" 12 #include "flutter/shell/platform/android/android_environment_gl.h" 13 #include "flutter/shell/platform/android/android_native_window.h" 14 #include "third_party/skia/include/core/SkSize.h" 15 16 namespace flutter { 17 18 class AndroidContextGL : public fml::RefCountedThreadSafe<AndroidContextGL> { 19 public: 20 bool CreateWindowSurface(fml::RefPtr<AndroidNativeWindow> window); 21 22 bool CreatePBufferSurface(); 23 24 fml::RefPtr<AndroidEnvironmentGL> Environment() const; 25 26 bool IsValid() const; 27 28 bool MakeCurrent(); 29 30 bool ClearCurrent(); 31 32 bool SwapBuffers(); 33 34 SkISize GetSize(); 35 36 bool Resize(const SkISize& size); 37 38 private: 39 fml::RefPtr<AndroidEnvironmentGL> environment_; 40 fml::RefPtr<AndroidNativeWindow> window_; 41 EGLConfig config_; 42 EGLSurface surface_; 43 EGLContext context_; 44 bool valid_; 45 46 AndroidContextGL(fml::RefPtr<AndroidEnvironmentGL> env, 47 const AndroidContextGL* share_context = nullptr); 48 49 ~AndroidContextGL(); 50 51 FML_FRIEND_MAKE_REF_COUNTED(AndroidContextGL); 52 FML_FRIEND_REF_COUNTED_THREAD_SAFE(AndroidContextGL); 53 FML_DISALLOW_COPY_AND_ASSIGN(AndroidContextGL); 54 }; 55 56 } // namespace flutter 57 58 #endif // FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_CONTEXT_GL_H_ 59