forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Impeller] Flutter GPU: Add GpuContext. (flutter#44359)
Move the GpuContext to its new home. I added a `flutter_tester` test that just verifies an exception is gracefully thrown when Impeller isn't available. In a later patch, I'll land a way to eagerly supply the Impeller context on the cpp side to enable testing through the playground (as mentioned in flutter/flutter#127712).
- Loading branch information
Showing
18 changed files
with
214 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# 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. | ||
|
||
linter: | ||
rules: | ||
- public_member_api_docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// 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. | ||
|
||
#pragma once | ||
|
||
#include "dart_api.h" | ||
#include "flutter/lib/gpu/export.h" | ||
#include "flutter/lib/ui/dart_wrapper.h" | ||
#include "impeller/renderer/context.h" | ||
|
||
namespace flutter { | ||
|
||
class Context : public RefCountedDartWrappable<Context> { | ||
DEFINE_WRAPPERTYPEINFO(); | ||
FML_FRIEND_MAKE_REF_COUNTED(Context); | ||
|
||
public: | ||
explicit Context(std::shared_ptr<impeller::Context> context); | ||
~Context() override; | ||
|
||
private: | ||
std::shared_ptr<impeller::Context> context_; | ||
|
||
FML_DISALLOW_COPY_AND_ASSIGN(Context); | ||
}; | ||
|
||
} // namespace flutter | ||
|
||
//---------------------------------------------------------------------------- | ||
/// Exports | ||
/// | ||
|
||
extern "C" { | ||
|
||
FLUTTER_GPU_EXPORT | ||
extern Dart_Handle InternalFlutterGpu_Context_InitializeDefault( | ||
Dart_Handle wrapper); | ||
|
||
} // extern "C" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// 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. | ||
|
||
#include "flutter/lib/gpu/export.h" | ||
|
||
namespace flutter { | ||
|
||
// | ||
|
||
} // namespace flutter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// 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. | ||
|
||
#pragma once | ||
|
||
#if FML_OS_WIN | ||
#define FLUTTER_GPU_EXPORT __declspec(dllexport) | ||
#else // FML_OS_WIN | ||
#define FLUTTER_GPU_EXPORT __attribute__((visibility("default"))) | ||
#endif // FML_OS_WIN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// 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. | ||
|
||
/// The Flutter GPU library. | ||
/// | ||
/// To use, import `package:flutter_gpu/gpu.dart`. | ||
/// | ||
/// See also: | ||
/// | ||
/// * [Flutter GPU Wiki page](https://github.com/flutter/flutter/wiki/Flutter-GPU). | ||
library flutter_gpu; | ||
|
||
export 'src/context.dart'; | ||
export 'src/smoketest.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// 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. | ||
|
||
import 'dart:ffi'; | ||
import 'dart:nativewrappers'; | ||
|
||
/// A handle to a graphics context. Used to create and manage GPU resources. | ||
/// | ||
/// To obtain the default graphics context, use [getContext]. | ||
class GpuContext extends NativeFieldWrapperClass1 { | ||
/// Creates a new graphics context that corresponds to the default Impeller | ||
/// context. | ||
GpuContext._createDefault() { | ||
final String? error = _initializeDefault(); | ||
if (error != null) { | ||
throw Exception(error); | ||
} | ||
} | ||
|
||
/// Associates the default Impeller context with this Context. | ||
@Native<Handle Function(Handle)>( | ||
symbol: 'InternalFlutterGpu_Context_InitializeDefault') | ||
external String? _initializeDefault(); | ||
} | ||
|
||
/// The default graphics context. | ||
final GpuContext gpuContext = GpuContext._createDefault(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# 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. | ||
|
||
name: flutter_gpu | ||
description: A framework for writing Flutter applications | ||
homepage: https://flutter.dev | ||
|
||
environment: | ||
sdk: '>=3.0.0-0 <4.0.0' | ||
|
||
dependencies: | ||
sky_engine: | ||
sdk: flutter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.