Flutter Impeller
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 
23 namespace impeller {
24 
25 std::unique_ptr<PlaygroundImpl> PlaygroundImpl::Create(
26  PlaygroundBackend backend,
27  PlaygroundSwitches switches) {
28  switch (backend) {
29 #if IMPELLER_ENABLE_METAL
31  return std::make_unique<PlaygroundImplMTL>(switches);
33  switches.flags.use_sdfs = true;
34  return std::make_unique<PlaygroundImplMTL>(switches);
35 #endif // IMPELLER_ENABLE_METAL
36 #if IMPELLER_ENABLE_OPENGLES
38  return std::make_unique<PlaygroundImplGLES>(switches);
40  switches.flags.use_sdfs = true;
41  return std::make_unique<PlaygroundImplGLES>(switches);
42 #endif // IMPELLER_ENABLE_OPENGLES
43 #if IMPELLER_ENABLE_VULKAN
46  FML_CHECK(false) << "Attempted to create playground with backend that "
47  "isn't available or was disabled on this platform: "
48  << PlaygroundBackendToString(backend);
49  }
50  switches.enable_vulkan_validation = true;
51  return std::make_unique<PlaygroundImplVK>(switches);
52 #endif // IMPELLER_ENABLE_VULKAN
53  default:
54  FML_CHECK(false) << "Attempted to create playground with backend that "
55  "isn't available or was disabled on this platform: "
56  << PlaygroundBackendToString(backend);
57  }
58  FML_UNREACHABLE();
59 }
60 
62  : switches_(switches) {}
63 
65 
67  auto window = reinterpret_cast<GLFWwindow*>(GetWindowHandle());
68 
69  Vector2 scale(1, 1);
70  ::glfwGetWindowContentScale(window, &scale.x, &scale.y);
71 
72  return scale;
73 }
74 
76  const {
77  return nullptr;
78 }
79 
81  const {
82  return nullptr;
83 }
84 
85 } // namespace impeller
std::function< void *(void *instance, const char *proc_name)> VKProcAddressResolver
Definition: playground.h:111
std::function< void *(const char *proc_name)> GLProcAddressResolver
Definition: playground.h:107
PlaygroundImpl(PlaygroundSwitches switches)
Vector2 GetContentScale() const
virtual WindowHandle GetWindowHandle() const =0
static std::unique_ptr< PlaygroundImpl > Create(PlaygroundBackend backend, PlaygroundSwitches switches)
virtual Playground::GLProcAddressResolver CreateGLProcAddressResolver() const
virtual Playground::VKProcAddressResolver CreateVKProcAddressResolver() const
std::string PlaygroundBackendToString(PlaygroundBackend backend)
Definition: playground.cc:48
PlaygroundBackend
Definition: playground.h:27
bool use_sdfs
Use SDFs for rendering.
Definition: flags.h:13