Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 18 additions & 20 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,24 @@ FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStan
FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodec_Internal.h
FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/flutter_codecs_unittest.mm
FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/flutter_standard_codec_unittest.mm
FILE: ../../../flutter/shell/platform/darwin/graphics/ios_context.h
FILE: ../../../flutter/shell/platform/darwin/graphics/ios_context.mm
FILE: ../../../flutter/shell/platform/darwin/graphics/ios_context_gl.h
FILE: ../../../flutter/shell/platform/darwin/graphics/ios_context_gl.mm
FILE: ../../../flutter/shell/platform/darwin/graphics/ios_context_metal.h
FILE: ../../../flutter/shell/platform/darwin/graphics/ios_context_metal.mm
FILE: ../../../flutter/shell/platform/darwin/graphics/ios_context_software.h
FILE: ../../../flutter/shell/platform/darwin/graphics/ios_context_software.mm
FILE: ../../../flutter/shell/platform/darwin/graphics/ios_external_texture_gl.h
FILE: ../../../flutter/shell/platform/darwin/graphics/ios_external_texture_gl.mm
FILE: ../../../flutter/shell/platform/darwin/graphics/ios_external_texture_metal.h
FILE: ../../../flutter/shell/platform/darwin/graphics/ios_external_texture_metal.mm
FILE: ../../../flutter/shell/platform/darwin/graphics/ios_render_target_gl.h
FILE: ../../../flutter/shell/platform/darwin/graphics/ios_render_target_gl.mm
FILE: ../../../flutter/shell/platform/darwin/graphics/ios_switchable_gl_context.h
FILE: ../../../flutter/shell/platform/darwin/graphics/ios_switchable_gl_context.mm
FILE: ../../../flutter/shell/platform/darwin/graphics/rendering_api_selection.h
FILE: ../../../flutter/shell/platform/darwin/graphics/rendering_api_selection.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Flutter.podspec
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/Flutter.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterAppDelegate.h
Expand Down Expand Up @@ -1005,38 +1023,18 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/profiler_metri
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/module.modulemap
FILE: ../../../flutter/shell/platform/darwin/ios/ios_context.h
FILE: ../../../flutter/shell/platform/darwin/ios/ios_context.mm
FILE: ../../../flutter/shell/platform/darwin/ios/ios_context_gl.h
FILE: ../../../flutter/shell/platform/darwin/ios/ios_context_gl.mm
FILE: ../../../flutter/shell/platform/darwin/ios/ios_context_metal.h
FILE: ../../../flutter/shell/platform/darwin/ios/ios_context_metal.mm
FILE: ../../../flutter/shell/platform/darwin/ios/ios_context_software.h
FILE: ../../../flutter/shell/platform/darwin/ios/ios_context_software.mm
FILE: ../../../flutter/shell/platform/darwin/ios/ios_external_texture_gl.h
FILE: ../../../flutter/shell/platform/darwin/ios/ios_external_texture_gl.mm
FILE: ../../../flutter/shell/platform/darwin/ios/ios_external_texture_metal.h
FILE: ../../../flutter/shell/platform/darwin/ios/ios_external_texture_metal.mm
FILE: ../../../flutter/shell/platform/darwin/ios/ios_external_view_embedder.h
FILE: ../../../flutter/shell/platform/darwin/ios/ios_external_view_embedder.mm
FILE: ../../../flutter/shell/platform/darwin/ios/ios_render_target_gl.h
FILE: ../../../flutter/shell/platform/darwin/ios/ios_render_target_gl.mm
FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface.h
FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface.mm
FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_factory.h
FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_factory.mm
FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_gl.h
FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_gl.mm
FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_metal.h
FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_metal.mm
FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_software.h
FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_software.mm
FILE: ../../../flutter/shell/platform/darwin/ios/ios_switchable_gl_context.h
FILE: ../../../flutter/shell/platform/darwin/ios/ios_switchable_gl_context.mm
FILE: ../../../flutter/shell/platform/darwin/ios/platform_view_ios.h
FILE: ../../../flutter/shell/platform/darwin/ios/platform_view_ios.mm
FILE: ../../../flutter/shell/platform/darwin/ios/rendering_api_selection.h
FILE: ../../../flutter/shell/platform/darwin/ios/rendering_api_selection.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/FlutterMacOS.podspec
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterAppDelegate.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterDartProject.h
Expand Down
1 change: 1 addition & 0 deletions flow/testing/gl_context_switch_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "flutter/common/graphics/gl_context_switch.h"
#include "gtest/gtest.h"

// TODO (kaushik): move to /flutter/common/graphics
namespace flutter {
namespace testing {

Expand Down
1 change: 1 addition & 0 deletions shell/common/persistent_cache_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "flutter/testing/testing.h"
#include "include/core/SkPicture.h"

// TODO(kaushik): move to /flutter/common/graphics
namespace flutter {
namespace testing {

Expand Down
65 changes: 65 additions & 0 deletions shell/platform/darwin/graphics/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

assert(is_ios)

import("//flutter/common/config.gni")
import("//flutter/shell/gpu/gpu.gni")
import("//flutter/shell/platform/darwin/common/framework_shared.gni")

shell_gpu_configuration("ios_gpu_configuration") {
enable_software = true
enable_gl = true
enable_vulkan = false
enable_metal = shell_enable_metal
}

source_set("flutter_ios_graphics") {
cflags_objc = flutter_cflags_objc
cflags_objcc = flutter_cflags_objcc
defines = []

sources = [
"ios_context.h",
"ios_context.mm",
"ios_context_gl.h",
"ios_context_gl.mm",
"ios_context_software.h",
"ios_context_software.mm",
"ios_external_texture_gl.h",
"ios_external_texture_gl.mm",
"ios_render_target_gl.h",
"ios_render_target_gl.mm",
"ios_switchable_gl_context.h",
"ios_switchable_gl_context.mm",
"rendering_api_selection.h",
"rendering_api_selection.mm",
]

if (shell_enable_metal) {
defines += [ "FLUTTER_SHELL_ENABLE_METAL=1" ]

sources += [
"ios_context_metal.h",
"ios_context_metal.mm",
"ios_external_texture_metal.h",
"ios_external_texture_metal.mm",
]
}

deps = [
":ios_gpu_configuration",
"//flutter/fml",
"//flutter/common/graphics",
"//flutter/shell/platform/darwin/common:framework_shared",
"//third_party/skia",
]

libs = [
"CoreMedia.framework",
"CoreVideo.framework",
"OpenGLES.framework",
"QuartzCore.framework",
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_RESOURCE_CONTEXT_H_
#define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_RESOURCE_CONTEXT_H_
#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_GRAPHICS_IOS_RESOURCE_CONTEXT_H_
#define FLUTTER_SHELL_PLATFORM_DARWIN_GRAPHICS_IOS_RESOURCE_CONTEXT_H_

#include <memory>

#include "flutter/common/graphics/gl_context_switch.h"
#include "flutter/common/graphics/texture.h"
#include "flutter/fml/macros.h"
#include "flutter/fml/platform/darwin/scoped_nsobject.h"
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterTexture.h"
#import "flutter/shell/platform/darwin/ios/rendering_api_selection.h"
#import "flutter/shell/platform/darwin/graphics/rendering_api_selection.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"

namespace flutter {
Expand Down Expand Up @@ -90,7 +88,7 @@ class IOSContext {
/// bound to the current
/// thread.
///
virtual std::unique_ptr<GLContextResult> MakeCurrent() = 0;
virtual std::unique_ptr<GLContextResult> MakeCurrent() const = 0;

//----------------------------------------------------------------------------
/// @brief Creates an external texture proxy of the appropriate client
Expand All @@ -115,4 +113,4 @@ class IOSContext {

} // namespace flutter

#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_RESOURCE_CONTEXT_H_
#endif // FLUTTER_SHELL_PLATFORM_DARWIN_GRAPHICS_IOS_RESOURCE_CONTEXT_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "flutter/shell/platform/darwin/ios/ios_context.h"
#import "flutter/shell/platform/darwin/graphics/ios_context.h"

#include "flutter/fml/logging.h"
#import "flutter/shell/platform/darwin/ios/ios_context_gl.h"
#import "flutter/shell/platform/darwin/ios/ios_context_software.h"
#import "flutter/shell/platform/darwin/graphics/ios_context_gl.h"
#import "flutter/shell/platform/darwin/graphics/ios_context_software.h"

#if FLUTTER_SHELL_ENABLE_METAL
#import "flutter/shell/platform/darwin/ios/ios_context_metal.h"
#import "flutter/shell/platform/darwin/graphics/ios_context_metal.h"
#endif // FLUTTER_SHELL_ENABLE_METAL

namespace flutter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_GL_CONTEXT_H_
#define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_GL_CONTEXT_H_
#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_GRAPHICS_IOS_GL_CONTEXT_H_
#define FLUTTER_SHELL_PLATFORM_DARWIN_GRAPHICS_IOS_GL_CONTEXT_H_

#include "flutter/fml/macros.h"
#include "flutter/fml/platform/darwin/scoped_nsobject.h"
#include "flutter/shell/common/platform_view.h"
#import "flutter/shell/platform/darwin/ios/ios_context.h"
#import "flutter/shell/platform/darwin/ios/ios_context_gl.h"
#import "flutter/shell/platform/darwin/ios/ios_render_target_gl.h"
#import "flutter/shell/platform/darwin/graphics/ios_context.h"
#import "flutter/shell/platform/darwin/graphics/ios_context_gl.h"
#import "flutter/shell/platform/darwin/graphics/ios_render_target_gl.h"

@class CAEAGLLayer;

Expand All @@ -23,7 +22,8 @@ class IOSContextGL final : public IOSContext {
// |IOSContext|
~IOSContextGL() override;

std::unique_ptr<IOSRenderTargetGL> CreateRenderTarget(fml::scoped_nsobject<CAEAGLLayer> layer);
std::unique_ptr<IOSRenderTargetGL> CreateRenderTarget(
fml::scoped_nsobject<CAEAGLLayer> layer) const;

private:
fml::scoped_nsobject<EAGLContext> context_;
Expand All @@ -33,7 +33,7 @@ class IOSContextGL final : public IOSContext {
sk_sp<GrDirectContext> CreateResourceContext() override;

// |IOSContext|
std::unique_ptr<GLContextResult> MakeCurrent() override;
std::unique_ptr<GLContextResult> MakeCurrent() const override;

// |IOSContext|
std::unique_ptr<Texture> CreateExternalTexture(
Expand All @@ -45,4 +45,4 @@ class IOSContextGL final : public IOSContext {

} // namespace flutter

#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_GL_CONTEXT_H_
#endif // FLUTTER_SHELL_PLATFORM_DARWIN_GRAPHICS_IOS_GL_CONTEXT_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,48 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "flutter/shell/platform/darwin/ios/ios_context_gl.h"
#import "flutter/shell/platform/darwin/graphics/ios_context_gl.h"

#import <OpenGLES/EAGL.h>

#include "flutter/shell/common/shell_io_manager.h"
#include "flutter/common/graphics/persistent_cache.h"
#include "flutter/shell/gpu/gpu_surface_gl_delegate.h"
#import "flutter/shell/platform/darwin/ios/ios_external_texture_gl.h"
#import "flutter/shell/platform/darwin/graphics/ios_external_texture_gl.h"

namespace flutter {

static sk_sp<GrDirectContext> CreateCompatibleResourceLoadingContext(
sk_sp<const GrGLInterface> gl_interface) {
GrContextOptions options = {};
if (PersistentCache::cache_sksl()) {
FML_LOG(INFO) << "Cache SkSL";
options.fShaderCacheStrategy = GrContextOptions::ShaderCacheStrategy::kSkSL;
}
PersistentCache::MarkStrategySet();

options.fPersistentCache = PersistentCache::GetCacheForProcess();

// There is currently a bug with doing GPU YUV to RGB conversions on the IO
// thread. The necessary work isn't being flushed or synchronized with the
// other threads correctly, so the textures end up blank. For now, suppress
// that feature, which will cause texture uploads to do CPU YUV conversion.
// A similar work-around is also used in shell/gpu/gpu_surface_gl.cc.
options.fDisableGpuYUVConversion = true;

// To get video playback on the widest range of devices, we limit Skia to
// ES2 shading language when the ES3 external image extension is missing.
options.fPreferExternalImagesOverES3 = true;

if (auto context = GrDirectContext::MakeGL(gl_interface, options)) {
// Do not cache textures created by the image decoder. These textures
// should be deleted when they are no longer referenced by an SkImage.
context->setResourceCacheLimits(0, 0);
return context;
}

return nullptr;
}

IOSContextGL::IOSContextGL() {
resource_context_.reset([[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3]);
if (resource_context_ != nullptr) {
Expand All @@ -27,7 +59,7 @@
IOSContextGL::~IOSContextGL() = default;

std::unique_ptr<IOSRenderTargetGL> IOSContextGL::CreateRenderTarget(
fml::scoped_nsobject<CAEAGLLayer> layer) {
fml::scoped_nsobject<CAEAGLLayer> layer) const {
return std::make_unique<IOSRenderTargetGL>(std::move(layer), context_);
}

Expand All @@ -39,12 +71,12 @@
return nullptr;
}

return ShellIOManager::CreateCompatibleResourceLoadingContext(
GrBackend::kOpenGL_GrBackend, GPUSurfaceGLDelegate::GetDefaultPlatformGLInterface());
return CreateCompatibleResourceLoadingContext(
GPUSurfaceGLDelegate::GetDefaultPlatformGLInterface());
}

// |IOSContext|
std::unique_ptr<GLContextResult> IOSContextGL::MakeCurrent() {
std::unique_ptr<GLContextResult> IOSContextGL::MakeCurrent() const {
return std::make_unique<GLContextSwitch>(
std::make_unique<IOSSwitchableGLContext>(context_.get()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_CONTEXT_METAL_H_
#define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_CONTEXT_METAL_H_
#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_GRAPHICS_IOS_CONTEXT_METAL_H_
#define FLUTTER_SHELL_PLATFORM_DARWIN_GRAPHICS_IOS_CONTEXT_METAL_H_

#include <Metal/Metal.h>

#include "flutter/fml/macros.h"
#include "flutter/fml/platform/darwin/cf_utils.h"
#include "flutter/fml/platform/darwin/scoped_nsobject.h"
#import "flutter/shell/platform/darwin/ios/ios_context.h"
#import "flutter/shell/platform/darwin/graphics/ios_context.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"

namespace flutter {
Expand Down Expand Up @@ -42,7 +42,7 @@ class IOSContextMetal final : public IOSContext {
sk_sp<GrDirectContext> CreateResourceContext() override;

// |IOSContext|
std::unique_ptr<GLContextResult> MakeCurrent() override;
std::unique_ptr<GLContextResult> MakeCurrent() const override;

// |IOSContext|
std::unique_ptr<Texture> CreateExternalTexture(
Expand All @@ -54,4 +54,4 @@ class IOSContextMetal final : public IOSContext {

} // namespace flutter

#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_CONTEXT_METAL_H_
#endif // FLUTTER_SHELL_PLATFORM_DARWIN_GRAPHICS_IOS_CONTEXT_METAL_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "flutter/shell/platform/darwin/ios/ios_context_metal.h"
#import "flutter/shell/platform/darwin/graphics/ios_context_metal.h"

#include "flutter/common/graphics/persistent_cache.h"
#include "flutter/fml/logging.h"
#import "flutter/shell/platform/darwin/ios/ios_external_texture_metal.h"
#import "flutter/shell/platform/darwin/graphics/ios_external_texture_metal.h"
#include "third_party/skia/include/gpu/GrContextOptions.h"

namespace flutter {
Expand Down Expand Up @@ -96,7 +96,7 @@ static GrContextOptions CreateMetalGrContextOptions() {
}

// |IOSContext|
std::unique_ptr<GLContextResult> IOSContextMetal::MakeCurrent() {
std::unique_ptr<GLContextResult> IOSContextMetal::MakeCurrent() const {
// This only makes sense for context that need to be bound to a specific thread.
return std::make_unique<GLContextDefaultResult>(true);
}
Expand Down
Loading