| 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
5 #include "impeller/playground/playground_impl.h"
6
7 #define GLFW_INCLUDE_NONE
8 #include "third_party/glfw/include/GLFW/glfw3.h"
9
10 #if IMPELLER_ENABLE_METAL
11 #include "impeller/playground/backend/metal/playground_impl_mtl.h"
12 #endif // IMPELLER_ENABLE_METAL
13
14 #if IMPELLER_ENABLE_OPENGLES
15 #include "impeller/playground/backend/gles/playground_impl_gles.h"
16 #endif // IMPELLER_ENABLE_OPENGLES
17
18 #if IMPELLER_ENABLE_VULKAN
19 #include "impeller/playground/backend/vulkan/playground_impl_vk.h"
20 #endif // IMPELLER_ENABLE_VULKAN
21
22 namespace impeller {
23
24 std::unique_ptr<PlaygroundImpl> PlaygroundImpl::Create(
25 PlaygroundBackend backend,
26 PlaygroundSwitches switches) {
27 switch (backend) {
28 #if IMPELLER_ENABLE_METAL
29 case PlaygroundBackend::kMetal:
30 return std::make_unique<PlaygroundImplMTL>(switches);
31 #endif // IMPELLER_ENABLE_METAL
32 #if IMPELLER_ENABLE_OPENGLES
33 case PlaygroundBackend::kOpenGLES:
34 return std::make_unique<PlaygroundImplGLES>(switches);
35 #endif // IMPELLER_ENABLE_OPENGLES
36 #if IMPELLER_ENABLE_VULKAN
37 case PlaygroundBackend::kVulkan:
38 return std::make_unique<PlaygroundImplVK>(switches);
39 #endif // IMPELLER_ENABLE_VULKAN
40 default:
41 FML_CHECK(false) << "Attempted to create playground with backend that "
42 "isn't available or was disabled on this platform: "
43 << PlaygroundBackendToString(backend);
44 }
45 FML_UNREACHABLE();
46 }
47
48 PlaygroundImpl::PlaygroundImpl(PlaygroundSwitches switches)
49 : switches_(switches) {}
50
51 PlaygroundImpl::~PlaygroundImpl() = default;
52
53 Vector2 PlaygroundImpl::GetContentScale() const {
54 auto window = reinterpret_cast<GLFWwindow*>(GetWindowHandle());
55
56 Vector2 scale(1, 1);
57 ::glfwGetWindowContentScale(window, &scale.x, &scale.y);
58
59 return scale;
60 }
61
62 } // namespace impeller
impeller::PlaygroundBackend::kVulkan
@ kVulkan
impeller::TPoint::y
Type y
Definition: point.h:26
playground_impl_gles.h
impeller::PlaygroundBackend::kMetal
@ kMetal
impeller::PlaygroundBackendToString
std::string PlaygroundBackendToString(PlaygroundBackend backend)
Definition: playground.cc:39
impeller::PlaygroundBackend
PlaygroundBackend
Definition: playground.h:29
impeller::PlaygroundImpl::~PlaygroundImpl
virtual ~PlaygroundImpl()
impeller::PlaygroundImpl::GetContentScale
Vector2 GetContentScale() const
Definition: playground_impl.cc:53
playground_impl_mtl.h
impeller::PlaygroundImpl::Create
static std::unique_ptr< PlaygroundImpl > Create(PlaygroundBackend backend, PlaygroundSwitches switches)
Definition: playground_impl.cc:24
impeller::TPoint::x
Type x
Definition: point.h:25
impeller::PlaygroundImpl::GetWindowHandle
virtual WindowHandle GetWindowHandle() const =0
impeller::PlaygroundBackend::kOpenGLES
@ kOpenGLES
playground_impl_vk.h
impeller::PlaygroundSwitches
Definition: switches.h:16
impeller::TPoint< Scalar >
playground_impl.h
impeller::PlaygroundImpl::PlaygroundImpl
PlaygroundImpl(PlaygroundSwitches switches)
Definition: playground_impl.cc:48
impeller
Definition: aiks_context.cc:10