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_DARWIN_IOS_IOS_GL_RENDER_TARGET_H_ 6 #define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_GL_RENDER_TARGET_H_ 7 8 #import <OpenGLES/EAGL.h> 9 #import <OpenGLES/ES2/gl.h> 10 #import <OpenGLES/ES2/glext.h> 11 #import <QuartzCore/CAEAGLLayer.h> 12 13 #include "flutter/fml/macros.h" 14 #include "flutter/fml/platform/darwin/scoped_nsobject.h" 15 #include "flutter/shell/common/platform_view.h" 16 17 namespace flutter { 18 19 class IOSGLRenderTarget { 20 public: 21 IOSGLRenderTarget(fml::scoped_nsobject<CAEAGLLayer> layer, 22 EAGLContext* context, 23 EAGLContext* resource_context); 24 25 ~IOSGLRenderTarget(); 26 27 bool IsValid() const; 28 29 bool PresentRenderBuffer() const; 30 framebuffer()31 GLuint framebuffer() const { return framebuffer_; } 32 33 bool UpdateStorageSizeIfNecessary(); 34 35 bool MakeCurrent(); 36 37 bool ResourceMakeCurrent(); 38 ColorSpace()39 sk_sp<SkColorSpace> ColorSpace() const { return color_space_; } 40 41 private: 42 fml::scoped_nsobject<CAEAGLLayer> layer_; 43 fml::scoped_nsobject<EAGLContext> context_; 44 fml::scoped_nsobject<EAGLContext> resource_context_; 45 GLuint framebuffer_; 46 GLuint colorbuffer_; 47 GLint storage_size_width_; 48 GLint storage_size_height_; 49 sk_sp<SkColorSpace> color_space_; 50 bool valid_; 51 52 FML_DISALLOW_COPY_AND_ASSIGN(IOSGLRenderTarget); 53 }; 54 55 } // namespace flutter 56 57 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_GL_RENDER_TARGET_H_ 58