| Flutter macOS Embedder |

Classes | Functions | Variables
FlutterSurfaceManager.mm File Reference
`#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.h"`
`#import <Metal/Metal.h>`
`#include <algorithm>`
`#include "flutter/fml/logging.h"`
`#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterSurface.h"`

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

## Function Documentation

## ◆ GetBorderColorForLayer()

static NSColor* GetBorderColorForLayer | ( | int | layer | ) |
| static

Definition at line 46 of file FlutterSurfaceManager.mm.

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

## ◆ 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 61 of file FlutterSurfaceManager.mm.

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

## Variable Documentation

## ◆ kIdleDelay

const double kIdleDelay = 1.0
| static

Definition at line 236 of file FlutterSurfaceManager.mm.