mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
The Google style guide specifies a limit of 100 columns. https://google.github.io/styleguide/objcguide.xml?showone=Line_Length#Line_Length The Chromium style guide specifies 80. https://chromium.googlesource.com/chromium/src/+/master/styleguide/objective-c/objective-c.md
44 lines
1.3 KiB
Plaintext
44 lines
1.3 KiB
Plaintext
// Copyright 2017 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "flutter/shell/platform/darwin/ios/ios_surface.h"
|
|
|
|
#include <flutter/shell/platform/darwin/ios/ios_surface_gl.h>
|
|
#include <flutter/shell/platform/darwin/ios/ios_surface_software.h>
|
|
#include <memory>
|
|
|
|
@class CALayer;
|
|
@class CAEAGLLayer;
|
|
|
|
namespace shell {
|
|
|
|
std::unique_ptr<IOSSurface> IOSSurface::Create(PlatformView::SurfaceConfig surface_config,
|
|
CALayer* layer) {
|
|
// Check if we can use OpenGL.
|
|
if ([layer isKindOfClass:[CAEAGLLayer class]]) {
|
|
return std::make_unique<IOSSurfaceGL>(surface_config, reinterpret_cast<CAEAGLLayer*>(layer));
|
|
}
|
|
|
|
// If we ever support the metal rendering API, a check for CAMetalLayer would
|
|
// go here.
|
|
|
|
// Finally, fallback to software rendering.
|
|
return std::make_unique<IOSSurfaceSoftware>(surface_config, layer);
|
|
}
|
|
|
|
IOSSurface::IOSSurface(PlatformView::SurfaceConfig surface_config, CALayer* layer)
|
|
: surface_config_(surface_config), layer_([layer retain]) {}
|
|
|
|
IOSSurface::~IOSSurface() = default;
|
|
|
|
CALayer* IOSSurface::GetLayer() const {
|
|
return layer_;
|
|
}
|
|
|
|
PlatformView::SurfaceConfig IOSSurface::GetSurfaceConfig() const {
|
|
return surface_config_;
|
|
}
|
|
|
|
} // namespace shell
|