Flutter Engine
 
Loading...
Searching...
No Matches
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
6
7#include <CoreGraphics/CGColorSpace.h>
8
11
13
14// This is mostly a duplication of FlutterView.
15@implementation FlutterOverlayView {
16 fml::CFRef<CGColorSpaceRef> _colorSpaceRef;
17}
18
19- (instancetype)initWithFrame:(CGRect)frame {
20 NSAssert(NO, @"FlutterOverlayView must init or initWithContentsScale");
21 return nil;
22}
23
24- (instancetype)initWithCoder:(NSCoder*)aDecoder {
25 NSAssert(NO, @"FlutterOverlayView must init or initWithContentsScale");
26 return nil;
27}
28
29- (instancetype)init {
30 self = [super initWithFrame:CGRectZero];
31
32 if (self) {
33 self.layer.opaque = NO;
34 self.userInteractionEnabled = NO;
35 self.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
36 }
37
38 return self;
39}
40
41- (instancetype)initWithContentsScale:(CGFloat)contentsScale
42 pixelFormat:(MTLPixelFormat)pixelFormat {
43 self = [self init];
44
45 if ([self.layer isKindOfClass:[CAMetalLayer class]]) {
46 self.layer.allowsGroupOpacity = NO;
47 self.layer.contentsScale = contentsScale;
48 self.layer.rasterizationScale = contentsScale;
49#pragma clang diagnostic push
50#pragma clang diagnostic ignored "-Wunguarded-availability-new"
51 CAMetalLayer* layer = (CAMetalLayer*)self.layer;
52#pragma clang diagnostic pop
53 layer.pixelFormat = pixelFormat;
54 if (pixelFormat == MTLPixelFormatRGBA16Float || pixelFormat == MTLPixelFormatBGRA10_XR) {
55 self->_colorSpaceRef = fml::CFRef(CGColorSpaceCreateWithName(kCGColorSpaceExtendedSRGB));
56 layer.colorspace = self->_colorSpaceRef;
57 }
58 }
59 return self;
60}
61
62+ (Class)layerClass {
63 return [FlutterView layerClass];
64}
65
66// TODO(amirh): implement drawLayer to support snapshotting.
67
68@end
instancetype initWithFrame
instancetype initWithCoder