Flutter Engine
The Flutter Engine
FlutterOverlayView.mm
Go to the documentation of this file.
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#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.h"
6
7#include <CoreGraphics/CGColorSpace.h>
8
9#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterView.h"
11
13
14// This is mostly a duplication of FlutterView.
15// TODO(amirh): once GL support is in evaluate if we can merge this with FlutterView.
16@implementation FlutterOverlayView {
17 fml::CFRef<CGColorSpaceRef> _colorSpaceRef;
18}
19
20- (instancetype)initWithFrame:(CGRect)frame {
21 NSAssert(NO, @"FlutterOverlayView must init or initWithContentsScale");
22 return nil;
23}
24
25- (instancetype)initWithCoder:(NSCoder*)aDecoder {
26 NSAssert(NO, @"FlutterOverlayView must init or initWithContentsScale");
27 return nil;
28}
29
30- (instancetype)init {
31 self = [super initWithFrame:CGRectZero];
32
33 if (self) {
34 self.layer.opaque = NO;
35 self.userInteractionEnabled = NO;
36 self.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
37 }
38
39 return self;
40}
41
42- (instancetype)initWithContentsScale:(CGFloat)contentsScale
43 pixelFormat:(MTLPixelFormat)pixelFormat {
44 self = [self init];
45
46 if ([self.layer isKindOfClass:NSClassFromString(@"CAMetalLayer")]) {
47 self.layer.allowsGroupOpacity = NO;
48 self.layer.contentsScale = contentsScale;
49 self.layer.rasterizationScale = contentsScale;
50#pragma clang diagnostic push
51#pragma clang diagnostic ignored "-Wunguarded-availability-new"
52 CAMetalLayer* layer = (CAMetalLayer*)self.layer;
53#pragma clang diagnostic pop
54 layer.pixelFormat = pixelFormat;
55 if (pixelFormat == MTLPixelFormatRGBA16Float || pixelFormat == MTLPixelFormatBGRA10_XR) {
56 self->_colorSpaceRef = fml::CFRef(CGColorSpaceCreateWithName(kCGColorSpaceExtendedSRGB));
57 layer.colorspace = self->_colorSpaceRef;
58 }
59 }
60 return self;
61}
62
63+ (Class)layerClass {
64 return [FlutterView layerClass];
65}
66
67// TODO(amirh): implement drawLayer to support snapshotting.
68
69@end
static std::function< void(void)> pop(std::deque< std::function< void(void)> > *list)
Definition: SkExecutor.cpp:62
if(end==-1)
Class layerClass()
Definition: FlutterView.mm:137
instancetype initWithFrame
instancetype initWithCoder
static bool init()