mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Currently, all our host unit-tests that have rendering concerns use the software backend because of OpenGL ES availability and stability issues on the various platforms where we run host tests. Unfortunately, entire subsystems are disabled (and not tested) when rendering with the software backend. This patch pulls in SwiftShader and via pending patches in the buildroot, configures the host unit-tests to optionally use OpenGL ES in a stable manner without relying on the OpenGL drivers being present (and functional). I have wired up the embedder test fixture in this patch to use the SwiftShader based OpenGL ES driver. I will update the shell and runtime unittests in a subsequent patch as well. The on and offscreen surfaces are configured as 1x1 pbuffer surface because we should be able to write pixel tests using OpenGL directly wihout having to deal with surfaces.
100 lines
2.8 KiB
C++
100 lines
2.8 KiB
C++
// 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_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_CONTEXT_H_
|
|
#define FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_CONTEXT_H_
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "flutter/fml/closure.h"
|
|
#include "flutter/fml/macros.h"
|
|
#include "flutter/fml/mapping.h"
|
|
#include "flutter/shell/platform/embedder/embedder.h"
|
|
#include "flutter/shell/platform/embedder/tests/embedder_test_gl_surface.h"
|
|
#include "flutter/testing/test_dart_native_resolver.h"
|
|
|
|
namespace flutter {
|
|
namespace testing {
|
|
|
|
using SemanticsNodeCallback = std::function<void(const FlutterSemanticsNode*)>;
|
|
using SemanticsActionCallback =
|
|
std::function<void(const FlutterSemanticsCustomAction*)>;
|
|
|
|
class EmbedderContext {
|
|
public:
|
|
EmbedderContext(std::string assets_path = "");
|
|
|
|
~EmbedderContext();
|
|
|
|
const std::string& GetAssetsPath() const;
|
|
|
|
const fml::Mapping* GetVMSnapshotData() const;
|
|
|
|
const fml::Mapping* GetVMSnapshotInstructions() const;
|
|
|
|
const fml::Mapping* GetIsolateSnapshotData() const;
|
|
|
|
const fml::Mapping* GetIsolateSnapshotInstructions() const;
|
|
|
|
void AddIsolateCreateCallback(fml::closure closure);
|
|
|
|
void AddNativeCallback(const char* name, Dart_NativeFunction function);
|
|
|
|
void SetSemanticsNodeCallback(SemanticsNodeCallback update_semantics_node);
|
|
|
|
void SetSemanticsCustomActionCallback(
|
|
SemanticsActionCallback semantics_custom_action);
|
|
|
|
private:
|
|
// This allows the builder to access the hooks.
|
|
friend class EmbedderConfigBuilder;
|
|
|
|
std::string assets_path_;
|
|
std::unique_ptr<fml::Mapping> vm_snapshot_data_;
|
|
std::unique_ptr<fml::Mapping> vm_snapshot_instructions_;
|
|
std::unique_ptr<fml::Mapping> isolate_snapshot_data_;
|
|
std::unique_ptr<fml::Mapping> isolate_snapshot_instructions_;
|
|
std::vector<fml::closure> isolate_create_callbacks_;
|
|
std::shared_ptr<TestDartNativeResolver> native_resolver_;
|
|
SemanticsNodeCallback update_semantics_node_callback_;
|
|
SemanticsActionCallback update_semantics_custom_action_callback_;
|
|
std::unique_ptr<EmbedderTestGLSurface> gl_surface_; // lazy
|
|
|
|
static VoidCallback GetIsolateCreateCallbackHook();
|
|
|
|
static FlutterUpdateSemanticsNodeCallback
|
|
GetUpdateSemanticsNodeCallbackHook();
|
|
|
|
static FlutterUpdateSemanticsCustomActionCallback
|
|
GetUpdateSemanticsCustomActionCallbackHook();
|
|
|
|
void FireIsolateCreateCallbacks();
|
|
|
|
void SetNativeResolver();
|
|
|
|
void SetupOpenGLSurface();
|
|
|
|
bool GLMakeCurrent();
|
|
|
|
bool GLClearCurrent();
|
|
|
|
bool GLPresent();
|
|
|
|
uint32_t GLGetFramebuffer();
|
|
|
|
bool GLMakeResourceCurrent();
|
|
|
|
void* GLGetProcAddress(const char* name);
|
|
|
|
FML_DISALLOW_COPY_AND_ASSIGN(EmbedderContext);
|
|
};
|
|
|
|
} // namespace testing
|
|
} // namespace flutter
|
|
|
|
#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_CONTEXT_H_
|