[Impeller] Flutter GPU: Add GpuContext. (#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 https://github.com/flutter/flutter/issues/127712).
diff --git a/ci/licenses_golden/excluded_files b/ci/licenses_golden/excluded_files
index 5beeafd..a4ce479 100644
--- a/ci/licenses_golden/excluded_files
+++ b/ci/licenses_golden/excluded_files
@@ -174,6 +174,8 @@
 ../../../flutter/impeller/tools/malioc_diff.py
 ../../../flutter/impeller/tools/xxd.py
 ../../../flutter/impeller/typographer/typographer_unittests.cc
+../../../flutter/lib/gpu/analysis_options.yaml
+../../../flutter/lib/gpu/pubspec.yaml
 ../../../flutter/lib/snapshot/libraries.json
 ../../../flutter/lib/snapshot/libraries.yaml
 ../../../flutter/lib/snapshot/pubspec.yaml
diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter
index e5a2f41..7cf45a5 100644
--- a/ci/licenses_golden/licenses_flutter
+++ b/ci/licenses_golden/licenses_flutter
@@ -1725,9 +1725,15 @@
 ORIGIN: ../../../flutter/impeller/typographer/text_run.h + ../../../flutter/LICENSE
 ORIGIN: ../../../flutter/impeller/typographer/typeface.cc + ../../../flutter/LICENSE
 ORIGIN: ../../../flutter/impeller/typographer/typeface.h + ../../../flutter/LICENSE
-ORIGIN: ../../../flutter/lib/gpu/gpu.cc + ../../../flutter/LICENSE
-ORIGIN: ../../../flutter/lib/gpu/gpu.dart + ../../../flutter/LICENSE
-ORIGIN: ../../../flutter/lib/gpu/gpu.h + ../../../flutter/LICENSE
+ORIGIN: ../../../flutter/lib/gpu/context.cc + ../../../flutter/LICENSE
+ORIGIN: ../../../flutter/lib/gpu/context.h + ../../../flutter/LICENSE
+ORIGIN: ../../../flutter/lib/gpu/export.cc + ../../../flutter/LICENSE
+ORIGIN: ../../../flutter/lib/gpu/export.h + ../../../flutter/LICENSE
+ORIGIN: ../../../flutter/lib/gpu/lib/gpu.dart + ../../../flutter/LICENSE
+ORIGIN: ../../../flutter/lib/gpu/lib/src/context.dart + ../../../flutter/LICENSE
+ORIGIN: ../../../flutter/lib/gpu/lib/src/smoketest.dart + ../../../flutter/LICENSE
+ORIGIN: ../../../flutter/lib/gpu/smoketest.cc + ../../../flutter/LICENSE
+ORIGIN: ../../../flutter/lib/gpu/smoketest.h + ../../../flutter/LICENSE
 ORIGIN: ../../../flutter/lib/io/dart_io.cc + ../../../flutter/LICENSE
 ORIGIN: ../../../flutter/lib/io/dart_io.h + ../../../flutter/LICENSE
 ORIGIN: ../../../flutter/lib/snapshot/snapshot.h + ../../../flutter/LICENSE
@@ -1749,8 +1755,6 @@
 ORIGIN: ../../../flutter/lib/ui/experiments/ui.dart + ../../../flutter/LICENSE
 ORIGIN: ../../../flutter/lib/ui/floating_point.h + ../../../flutter/LICENSE
 ORIGIN: ../../../flutter/lib/ui/geometry.dart + ../../../flutter/LICENSE
-ORIGIN: ../../../flutter/lib/ui/gpu/context.cc + ../../../flutter/LICENSE
-ORIGIN: ../../../flutter/lib/ui/gpu/context.h + ../../../flutter/LICENSE
 ORIGIN: ../../../flutter/lib/ui/hash_codes.dart + ../../../flutter/LICENSE
 ORIGIN: ../../../flutter/lib/ui/hooks.dart + ../../../flutter/LICENSE
 ORIGIN: ../../../flutter/lib/ui/io_manager.cc + ../../../flutter/LICENSE
@@ -4445,9 +4449,15 @@
 FILE: ../../../flutter/impeller/typographer/text_run.h
 FILE: ../../../flutter/impeller/typographer/typeface.cc
 FILE: ../../../flutter/impeller/typographer/typeface.h
-FILE: ../../../flutter/lib/gpu/gpu.cc
-FILE: ../../../flutter/lib/gpu/gpu.dart
-FILE: ../../../flutter/lib/gpu/gpu.h
+FILE: ../../../flutter/lib/gpu/context.cc
+FILE: ../../../flutter/lib/gpu/context.h
+FILE: ../../../flutter/lib/gpu/export.cc
+FILE: ../../../flutter/lib/gpu/export.h
+FILE: ../../../flutter/lib/gpu/lib/gpu.dart
+FILE: ../../../flutter/lib/gpu/lib/src/context.dart
+FILE: ../../../flutter/lib/gpu/lib/src/smoketest.dart
+FILE: ../../../flutter/lib/gpu/smoketest.cc
+FILE: ../../../flutter/lib/gpu/smoketest.h
 FILE: ../../../flutter/lib/io/dart_io.cc
 FILE: ../../../flutter/lib/io/dart_io.h
 FILE: ../../../flutter/lib/snapshot/libraries_experimental.json
@@ -4470,8 +4480,6 @@
 FILE: ../../../flutter/lib/ui/experiments/ui.dart
 FILE: ../../../flutter/lib/ui/floating_point.h
 FILE: ../../../flutter/lib/ui/geometry.dart
-FILE: ../../../flutter/lib/ui/gpu/context.cc
-FILE: ../../../flutter/lib/ui/gpu/context.h
 FILE: ../../../flutter/lib/ui/hash_codes.dart
 FILE: ../../../flutter/lib/ui/hooks.dart
 FILE: ../../../flutter/lib/ui/io_manager.cc
diff --git a/lib/gpu/BUILD.gn b/lib/gpu/BUILD.gn
index 7b24bf4..1886376 100644
--- a/lib/gpu/BUILD.gn
+++ b/lib/gpu/BUILD.gn
@@ -30,10 +30,16 @@
     defines = []
   }
 
-  sources = [
-    "gpu.cc",
-    "gpu.h",
-  ]
+  if (!is_fuchsia) {
+    sources = [
+      "context.cc",
+      "context.h",
+      "export.cc",
+      "export.h",
+      "smoketest.cc",
+      "smoketest.h",
+    ]
+  }
   deps = [
     "//flutter/impeller",
     "//flutter/impeller/display_list:skia_conversions",
diff --git a/lib/gpu/analysis_options.yaml b/lib/gpu/analysis_options.yaml
new file mode 100644
index 0000000..ee294d5
--- /dev/null
+++ b/lib/gpu/analysis_options.yaml
@@ -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
diff --git a/lib/gpu/context.cc b/lib/gpu/context.cc
new file mode 100644
index 0000000..f56e938
--- /dev/null
+++ b/lib/gpu/context.cc
@@ -0,0 +1,55 @@
+// 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/context.h"
+
+#include <future>
+
+#include "dart_api.h"
+#include "flutter/lib/ui/ui_dart_state.h"
+#include "fml/make_copyable.h"
+#include "tonic/converter/dart_converter.h"
+
+namespace flutter {
+
+IMPLEMENT_WRAPPERTYPEINFO(gpu, Context);
+
+Context::Context(std::shared_ptr<impeller::Context> context)
+    : context_(std::move(context)) {}
+
+Context::~Context() = default;
+
+}  // namespace flutter
+
+//----------------------------------------------------------------------------
+/// Exports
+///
+
+Dart_Handle InternalFlutterGpu_Context_InitializeDefault(Dart_Handle wrapper) {
+  auto dart_state = flutter::UIDartState::Current();
+  if (!dart_state->IsImpellerEnabled()) {
+    return tonic::ToDart(
+        "Flutter GPU requires the Impeller rendering backend to be enabled.");
+  }
+
+  // Grab the Impeller context from the IO manager.
+
+  std::promise<std::shared_ptr<impeller::Context>> context_promise;
+  auto impeller_context_future = context_promise.get_future();
+  dart_state->GetTaskRunners().GetIOTaskRunner()->PostTask(
+      fml::MakeCopyable([promise = std::move(context_promise),
+                         io_manager = dart_state->GetIOManager()]() mutable {
+        promise.set_value(io_manager ? io_manager->GetImpellerContext()
+                                     : nullptr);
+      }));
+
+  auto impeller_context = impeller_context_future.get();
+  if (!impeller_context) {
+    return tonic::ToDart("Unable to retrieve the Impeller context.");
+  }
+  auto res = fml::MakeRefCounted<flutter::Context>(impeller_context);
+  res->AssociateWithDartWrapper(wrapper);
+
+  return Dart_Null();
+}
diff --git a/lib/gpu/context.h b/lib/gpu/context.h
new file mode 100644
index 0000000..6667e1b
--- /dev/null
+++ b/lib/gpu/context.h
@@ -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"
diff --git a/lib/gpu/export.cc b/lib/gpu/export.cc
new file mode 100644
index 0000000..43ecb08
--- /dev/null
+++ b/lib/gpu/export.cc
@@ -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
diff --git a/lib/gpu/export.h b/lib/gpu/export.h
new file mode 100644
index 0000000..488b61c
--- /dev/null
+++ b/lib/gpu/export.h
@@ -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
diff --git a/lib/gpu/lib/gpu.dart b/lib/gpu/lib/gpu.dart
new file mode 100644
index 0000000..72cf205
--- /dev/null
+++ b/lib/gpu/lib/gpu.dart
@@ -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';
diff --git a/lib/gpu/lib/src/context.dart b/lib/gpu/lib/src/context.dart
new file mode 100644
index 0000000..1c1be14
--- /dev/null
+++ b/lib/gpu/lib/src/context.dart
@@ -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();
diff --git a/lib/gpu/gpu.dart b/lib/gpu/lib/src/smoketest.dart
similarity index 94%
rename from lib/gpu/gpu.dart
rename to lib/gpu/lib/src/smoketest.dart
index 039d115..1a77d43 100644
--- a/lib/gpu/gpu.dart
+++ b/lib/gpu/lib/src/smoketest.dart
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-// ignore_for_file: public_member_api_docs
-
 import 'dart:ffi';
 import 'dart:nativewrappers';
 
@@ -11,10 +9,12 @@
 @Native<Int32 Function()>(symbol: 'InternalFlutterGpuTestProc')
 external int testProc();
 
+/// A single parameter callback.
+typedef Callback<T> = void Function(T result);
+
 /// This is a test callback that follows the same pattern as much of dart:ui --
 /// immediately returning an error string and supplying an asynchronous result
 /// via callback later.
-typedef Callback<T> = void Function(T result);
 @Native<Handle Function(Handle)>(
     symbol: 'InternalFlutterGpuTestProcWithCallback')
 external String? testProcWithCallback(Callback<int> callback);
@@ -22,6 +22,7 @@
 /// This is a test of NativeFieldWrapperClass1, which is commonly used in
 /// dart:ui to enable Dart to dictate the lifetime of a C counterpart.
 base class FlutterGpuTestClass extends NativeFieldWrapperClass1 {
+  /// Default constructor for the test class
   FlutterGpuTestClass() {
     _constructor();
   }
diff --git a/lib/gpu/pubspec.yaml b/lib/gpu/pubspec.yaml
new file mode 100644
index 0000000..a45d82d
--- /dev/null
+++ b/lib/gpu/pubspec.yaml
@@ -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
diff --git a/lib/gpu/gpu.cc b/lib/gpu/smoketest.cc
similarity index 88%
rename from lib/gpu/gpu.cc
rename to lib/gpu/smoketest.cc
index 4d6bf37..54411d7 100644
--- a/lib/gpu/gpu.cc
+++ b/lib/gpu/smoketest.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "flutter/lib/gpu/gpu.h"
+#include "flutter/lib/gpu/smoketest.h"
 #include "flutter/fml/memory/ref_ptr.h"
 #include "flutter/lib/ui/dart_wrapper.h"
 #include "flutter/lib/ui/ui_dart_state.h"
@@ -23,6 +23,10 @@
 
 }  // namespace flutter
 
+//----------------------------------------------------------------------------
+/// Exports
+///
+
 // TODO(131346): Remove this once we migrate the Dart GPU API into this space.
 uint32_t InternalFlutterGpuTestProc() {
   return 1;
@@ -52,9 +56,3 @@
                                         int something) {
   FML_LOG(INFO) << "Something: " << something;
 }
-
-// TODO(131346): Remove this once we migrate the Dart GPU API into this space.
-void FlutterGpuTestClass_Dispose(flutter::FlutterGpuTestClass* self,
-                                 int something) {
-  self->ClearDartWrapper();
-}
diff --git a/lib/gpu/gpu.h b/lib/gpu/smoketest.h
similarity index 80%
rename from lib/gpu/gpu.h
rename to lib/gpu/smoketest.h
index 0007845..d957b9d 100644
--- a/lib/gpu/gpu.h
+++ b/lib/gpu/smoketest.h
@@ -2,22 +2,16 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef FLUTTER_LIB_GPU_GPU_H_
-#define FLUTTER_LIB_GPU_GPU_H_
+#pragma once
 
 #include <cstdint>
 
+#include "flutter/lib/gpu/export.h"
 #include "flutter/lib/ui/dart_wrapper.h"
 #include "third_party/dart/runtime/include/dart_api.h"
 #include "third_party/tonic/dart_state.h"
 #include "third_party/tonic/dart_wrapper_info.h"
 
-#if FML_OS_WIN
-#define FLUTTER_EXPORT __declspec(dllexport)
-#else  // FML_OS_WIN
-#define FLUTTER_EXPORT __attribute__((visibility("default")))
-#endif  // FML_OS_WIN
-
 namespace flutter {
 
 // TODO(131346): Remove this once we migrate the Dart GPU API into this space.
@@ -32,26 +26,28 @@
 
 }  // namespace flutter
 
+//----------------------------------------------------------------------------
+/// Exports
+///
+
 extern "C" {
 
 // TODO(131346): Remove this once we migrate the Dart GPU API into this space.
-FLUTTER_EXPORT
+FLUTTER_GPU_EXPORT
 extern uint32_t InternalFlutterGpuTestProc();
 
 // TODO(131346): Remove this once we migrate the Dart GPU API into this space.
-FLUTTER_EXPORT
+FLUTTER_GPU_EXPORT
 extern Dart_Handle InternalFlutterGpuTestProcWithCallback(Dart_Handle callback);
 
 // TODO(131346): Remove this once we migrate the Dart GPU API into this space.
-FLUTTER_EXPORT
+FLUTTER_GPU_EXPORT
 extern void InternalFlutterGpuTestClass_Create(Dart_Handle wrapper);
 
 // TODO(131346): Remove this once we migrate the Dart GPU API into this space.
-FLUTTER_EXPORT
+FLUTTER_GPU_EXPORT
 extern void InternalFlutterGpuTestClass_Method(
     flutter::FlutterGpuTestClass* self,
     int something);
 
 }  // extern "C"
-
-#endif  // FLUTTER_LIB_GPU_GPU_H_
diff --git a/lib/ui/BUILD.gn b/lib/ui/BUILD.gn
index aae6a6e..596dac7 100644
--- a/lib/ui/BUILD.gn
+++ b/lib/ui/BUILD.gn
@@ -216,12 +216,6 @@
       "painting/scene/scene_shader.h",
     ]
 
-    # Experimental "Impeller Dart" API.
-    sources += [
-      "gpu/context.cc",
-      "gpu/context.h",
-    ]
-
     deps += [ "//flutter/impeller/scene" ]
   }
 }
diff --git a/lib/ui/dart_ui.cc b/lib/ui/dart_ui.cc
index efb5af0..b2fdbf8 100644
--- a/lib/ui/dart_ui.cc
+++ b/lib/ui/dart_ui.cc
@@ -12,7 +12,6 @@
 #include "flutter/lib/ui/compositing/scene.h"
 #include "flutter/lib/ui/compositing/scene_builder.h"
 #include "flutter/lib/ui/dart_runtime_hooks.h"
-#include "flutter/lib/ui/gpu/context.h"
 #include "flutter/lib/ui/isolate_name_server/isolate_name_server_natives.h"
 #include "flutter/lib/ui/painting/canvas.h"
 #include "flutter/lib/ui/painting/codec.h"
@@ -316,10 +315,6 @@
   V(SceneShader, SetCameraTransform, 2) \
   V(SceneShader, Dispose, 1)
 
-#define FFI_FUNCTION_LIST_GPU(V) V(GpuContext::InitializeDefault, 1)
-
-#define FFI_METHOD_LIST_GPU(V)
-
 #endif  // IMPELLER_ENABLE_3D
 
 #define FFI_FUNCTION_INSERT(FUNCTION, ARGS)     \
@@ -352,9 +347,6 @@
 #ifdef IMPELLER_ENABLE_3D
   FFI_FUNCTION_LIST_3D(FFI_FUNCTION_INSERT)
   FFI_METHOD_LIST_3D(FFI_METHOD_INSERT)
-
-  FFI_FUNCTION_LIST_GPU(FFI_FUNCTION_INSERT)
-  FFI_METHOD_LIST_GPU(FFI_METHOD_INSERT)
 #endif  // IMPELLER_ENABLE_3D
 }
 
diff --git a/lib/ui/gpu/context.cc b/lib/ui/gpu/context.cc
deleted file mode 100644
index c61b4d2..0000000
--- a/lib/ui/gpu/context.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-// 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/ui/gpu/context.h"
-
-#include <memory>
-#include <sstream>
-
-#include "flutter/fml/log_level.h"
-#include "flutter/fml/logging.h"
-#include "flutter/fml/make_copyable.h"
-#include "flutter/fml/memory/ref_ptr.h"
-#include "flutter/lib/ui/ui_dart_state.h"
-#include "third_party/tonic/dart_wrappable.h"
-
-namespace flutter {
-
-IMPLEMENT_WRAPPERTYPEINFO(ui, GpuContext);
-
-std::string GpuContext::InitializeDefault(Dart_Handle wrapper) {
-  auto dart_state = UIDartState::Current();
-  if (!dart_state->IsImpellerEnabled()) {
-    return "The GpuContext API requires the Impeller rendering backend to be "
-           "enabled.";
-  }
-
-  // Grab the Impeller context from the IO manager.
-
-  std::promise<std::shared_ptr<impeller::Context>> context_promise;
-  auto impeller_context_future = context_promise.get_future();
-  dart_state->GetTaskRunners().GetIOTaskRunner()->PostTask(
-      fml::MakeCopyable([promise = std::move(context_promise),
-                         io_manager = dart_state->GetIOManager()]() mutable {
-        promise.set_value(io_manager ? io_manager->GetImpellerContext()
-                                     : nullptr);
-      }));
-
-  auto impeller_context = impeller_context_future.get();
-  if (!impeller_context) {
-    return "Unable to retrieve the Impeller context.";
-  }
-  auto res = fml::MakeRefCounted<GpuContext>(impeller_context);
-  res->AssociateWithDartWrapper(wrapper);
-
-  return "";
-}
-
-GpuContext::GpuContext(std::shared_ptr<impeller::Context> context)
-    : context_(std::move(context)) {}
-
-GpuContext::~GpuContext() = default;
-
-}  // namespace flutter
diff --git a/lib/ui/gpu/context.h b/lib/ui/gpu/context.h
deleted file mode 100644
index 5d9056b..0000000
--- a/lib/ui/gpu/context.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// 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.
-
-#ifndef FLUTTER_LIB_UI_GPU_H_
-#define FLUTTER_LIB_UI_GPU_H_
-
-#include <memory>
-
-#include "flutter/fml/macros.h"
-#include "flutter/fml/memory/ref_counted.h"
-#include "flutter/lib/ui/dart_wrapper.h"
-#include "impeller/renderer/context.h"
-#include "third_party/tonic/dart_library_natives.h"
-#include "third_party/tonic/dart_wrappable.h"
-
-namespace flutter {
-
-class GpuContext : public RefCountedDartWrappable<GpuContext> {
-  DEFINE_WRAPPERTYPEINFO();
-  FML_FRIEND_MAKE_REF_COUNTED(GpuContext);
-
- public:
-  explicit GpuContext(std::shared_ptr<impeller::Context> context);
-  ~GpuContext() override;
-
-  static std::string InitializeDefault(Dart_Handle wrapper);
-
- private:
-  std::shared_ptr<impeller::Context> context_;
-
-  FML_DISALLOW_COPY_AND_ASSIGN(GpuContext);
-};
-
-}  // namespace flutter
-
-#endif  // FLUTTER_LIB_UI_GPU_H_
diff --git a/testing/dart/gpu_test.dart b/testing/dart/gpu_test.dart
index e6fab02..0c96b66 100644
--- a/testing/dart/gpu_test.dart
+++ b/testing/dart/gpu_test.dart
@@ -5,11 +5,11 @@
 // ignore_for_file: avoid_relative_lib_imports
 
 import 'package:litetest/litetest.dart';
-import '../../lib/gpu/gpu.dart' as gpu;
+import '../../lib/gpu/lib/gpu.dart' as gpu;
 
 void main() {
   // TODO(131346): Remove this once we migrate the Dart GPU API into this space.
-  test('no crash', () async {
+  test('smoketest', () async {
     final int result = gpu.testProc();
     expect(result, 1);
 
@@ -21,4 +21,17 @@
     final gpu.FlutterGpuTestClass a = gpu.FlutterGpuTestClass();
     a.coolMethod(9847);
   });
+
+  test('gpu.context throws exception for incompatible embedders', () async {
+    try {
+      // ignore: unnecessary_statements
+      gpu.gpuContext; // Force the
+      fail('Exception not thrown');
+    } catch (e) {
+      expect(
+          e.toString(),
+          contains(
+              'Flutter GPU requires the Impeller rendering backend to be enabled.'));
+    }
+  });
 }