Flutter Engine
The Flutter Engine
playground_impl.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6#include "flutter/testing/testing.h"
7
8#define GLFW_INCLUDE_NONE
9#include "third_party/glfw/include/GLFW/glfw3.h"
10
11#if IMPELLER_ENABLE_METAL
13#endif // IMPELLER_ENABLE_METAL
14
15#if IMPELLER_ENABLE_OPENGLES
17#endif // IMPELLER_ENABLE_OPENGLES
18
19#if IMPELLER_ENABLE_VULKAN
21#endif // IMPELLER_ENABLE_VULKAN
22
23namespace impeller {
24
25std::unique_ptr<PlaygroundImpl> PlaygroundImpl::Create(
27 PlaygroundSwitches switches) {
28 switch (backend) {
29#if IMPELLER_ENABLE_METAL
31 return std::make_unique<PlaygroundImplMTL>(switches);
32#endif // IMPELLER_ENABLE_METAL
33#if IMPELLER_ENABLE_OPENGLES
35 return std::make_unique<PlaygroundImplGLES>(switches);
36#endif // IMPELLER_ENABLE_OPENGLES
37#if IMPELLER_ENABLE_VULKAN
40 FML_CHECK(false) << "Attempted to create playground with backend that "
41 "isn't available or was disabled on this platform: "
43 }
44 switches.enable_vulkan_validation = true;
45 return std::make_unique<PlaygroundImplVK>(switches);
46#endif // IMPELLER_ENABLE_VULKAN
47 default:
48 FML_CHECK(false) << "Attempted to create playground with backend that "
49 "isn't available or was disabled on this platform: "
51 }
53}
54
56 : switches_(switches) {}
57
59
61 auto window = reinterpret_cast<GLFWwindow*>(GetWindowHandle());
62
63 Vector2 scale(1, 1);
64 ::glfwGetWindowContentScale(window, &scale.x, &scale.y);
65
66 return scale;
67}
68
69} // namespace impeller
const char * backend
PlaygroundImpl(PlaygroundSwitches switches)
Vector2 GetContentScale() const
virtual WindowHandle GetWindowHandle() const =0
static std::unique_ptr< PlaygroundImpl > Create(PlaygroundBackend backend, PlaygroundSwitches switches)
GLFWwindow * window
Definition: main.cc:45
#define FML_CHECK(condition)
Definition: logging.h:85
#define FML_UNREACHABLE()
Definition: logging.h:109
std::string PlaygroundBackendToString(PlaygroundBackend backend)
Definition: playground.cc:45
PlaygroundBackend
Definition: playground.h:27
const Scalar scale