Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
FlutterSurfaceManager.mm File Reference

Go to the source code of this file.

Functions

static NSColor * GetBorderColorForLayer (int layer)
 
static void UpdateContentSubLayers (CALayer *layer, IOSurfaceRef surface, CGFloat scale, CGSize surfaceSize, NSColor *borderColor, const std::vector< FlutterRect > &paintRegion)
 

Variables

static const double kIdleDelay = 1.0
 
static const int kSurfaceEvictionAge = 30
 

Function Documentation

◆ GetBorderColorForLayer()

static NSColor * GetBorderColorForLayer ( int  layer)
static

Definition at line 49 of file FlutterSurfaceManager.mm.

49 {
50 NSArray* colors = @[
51 [NSColor yellowColor],
52 [NSColor cyanColor],
53 [NSColor magentaColor],
54 [NSColor greenColor],
55 [NSColor purpleColor],
56 [NSColor orangeColor],
57 [NSColor blueColor],
58 ];
59 return colors[layer % colors.count];
60}

◆ UpdateContentSubLayers()

static void UpdateContentSubLayers ( CALayer *  layer,
IOSurfaceRef  surface,
CGFloat  scale,
CGSize  surfaceSize,
NSColor *  borderColor,
const std::vector< FlutterRect > &  paintRegion 
)
static

Creates sublayers for given layer, each one displaying a portion of the of the surface determined by a rectangle in the provided paint region.

Definition at line 64 of file FlutterSurfaceManager.mm.

69 {
70 // Adjust sublayer count to paintRegion count.
71 while (layer.sublayers.count > paintRegion.size()) {
72 [layer.sublayers.lastObject removeFromSuperlayer];
73 }
74
75 while (layer.sublayers.count < paintRegion.size()) {
76 CALayer* newLayer = [CALayer layer];
77 [layer addSublayer:newLayer];
78 }
79
80 for (size_t i = 0; i < paintRegion.size(); i++) {
81 CALayer* subLayer = [layer.sublayers objectAtIndex:i];
82 const auto& rect = paintRegion[i];
83 subLayer.frame = CGRectMake(rect.left / scale, rect.top / scale,
84 (rect.right - rect.left) / scale, (rect.bottom - rect.top) / scale);
85
86 double width = surfaceSize.width;
87 double height = surfaceSize.height;
88
89 subLayer.contentsRect =
90 CGRectMake(rect.left / width, rect.top / height, (rect.right - rect.left) / width,
91 (rect.bottom - rect.top) / height);
92
93 if (borderColor != nil) {
94 // Visualize sublayer
95 subLayer.borderColor = borderColor.CGColor;
96 subLayer.borderWidth = 1.0;
97 }
98
99 subLayer.contents = (__bridge id)surface;
100 }
101}
int32_t height
int32_t width
const uintptr_t id

References height, i, id, surface, and width.

Variable Documentation

◆ kIdleDelay

const double kIdleDelay = 1.0
static

Definition at line 286 of file FlutterSurfaceManager.mm.

◆ kSurfaceEvictionAge

const int kSurfaceEvictionAge = 30
static

Definition at line 291 of file FlutterSurfaceManager.mm.