| Flutter Impeller |

playground.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 <array>
6 #include <memory>
7 #include <optional>
8 #include <sstream>
9
10 #include "fml/closure.h"
11 #include "fml/time/time_point.h"
12 #include "impeller/playground/image/backends/skia/compressed_image_skia.h"
13 #include "impeller/playground/image/decompressed_image.h"
14 #include "impeller/renderer/command_buffer.h"
15 #include "impeller/runtime_stage/runtime_stage.h"
16
17 #define GLFW_INCLUDE_NONE
18 #include "third_party/glfw/include/GLFW/glfw3.h"
19
20 #include "flutter/fml/paths.h"
21 #include "impeller/base/validation.h"
22 #include "impeller/core/allocator.h"
23 #include "impeller/core/formats.h"
24 #include "impeller/playground/backend/vulkan/swiftshader_utilities.h"
25 #include "impeller/playground/image/compressed_image.h"
26 #include "impeller/playground/imgui/imgui_impl_impeller.h"
27 #include "impeller/playground/playground.h"
28 #include "impeller/playground/playground_impl.h"
29 #include "impeller/renderer/context.h"
30 #include "impeller/renderer/render_pass.h"
31 #include "impeller/renderer/renderer.h"
32 #include "third_party/imgui/backends/imgui_impl_glfw.h"
33 #include "third_party/imgui/imgui.h"
34
35 #if FML_OS_MACOSX
36 #include "fml/platform/darwin/scoped_nsautorelease_pool.h"
37 #endif // FML_OS_MACOSX
38
39 #if IMPELLER_ENABLE_VULKAN
40 #include "impeller/playground/backend/vulkan/playground_impl_vk.h"
41 #endif // IMPELLER_ENABLE_VULKAN
42
43 namespace impeller {
44
45 std::string PlaygroundBackendToString(PlaygroundBackend backend) {
46 switch (backend) {
47 case PlaygroundBackend::kMetal:
48 return "Metal";
49 case PlaygroundBackend::kOpenGLES:
50 return "OpenGLES";
51 case PlaygroundBackend::kVulkan:
52 return "Vulkan";
53 }
54 FML_UNREACHABLE();
55 }
56
57 static void InitializeGLFWOnce() {
58 // This guard is a hack to work around a problem where glfwCreateWindow
59 // hangs when opening a second window after GLFW has been reinitialized (for
60 // example, when flipping through multiple playground tests).
61 //
62 // Explanation:
63 // * glfwCreateWindow calls [NSApp run], which begins running the event
64 // loop on the current thread.
65 // * GLFW then immediately stops the loop when
66 // applicationDidFinishLaunching is fired.
67 // * applicationDidFinishLaunching is only ever fired once during the
68 // application's lifetime, so subsequent calls to [NSApp run] will always
69 // hang with this setup.
70 // * glfwInit resets the flag that guards against [NSApp run] being
71 // called a second time, which causes the subsequent `glfwCreateWindow`
72 // to hang indefinitely in the event loop, because
73 // applicationDidFinishLaunching is never fired.
74 static std::once_flag sOnceInitializer;
75 std::call_once(sOnceInitializer, []() {
76 ::glfwSetErrorCallback([](int code, const char* description) {
77 FML_LOG(ERROR) << "GLFW Error '" << description << "' (" << code << ").";
78 });
79 FML_CHECK(::glfwInit() == GLFW_TRUE);
80 });
81 }
82
83 Playground::Playground(PlaygroundSwitches switches) : switches_(switches) {
84 InitializeGLFWOnce();
85 SetupSwiftshaderOnce(switches_.use_swiftshader);
86 }
87
88 Playground::~Playground() = default;
89
90 std::shared_ptr<Context> Playground::GetContext() const {
91 return context_;
92 }
93
94 std::shared_ptr<Context> Playground::MakeContext() const {
95 // Playgrounds are already making a context for each test, so we can just
96 // return the `context_`.
97 return context_;
98 }
99
100 bool Playground::SupportsBackend(PlaygroundBackend backend) {
101 switch (backend) {
102 case PlaygroundBackend::kMetal:
103 #if IMPELLER_ENABLE_METAL
104 return true;
105 #else // IMPELLER_ENABLE_METAL
106 return false;
107 #endif // IMPELLER_ENABLE_METAL
108 case PlaygroundBackend::kOpenGLES:
109 #if IMPELLER_ENABLE_OPENGLES
110 return true;
111 #else // IMPELLER_ENABLE_OPENGLES
112 return false;
113 #endif // IMPELLER_ENABLE_OPENGLES
114 case PlaygroundBackend::kVulkan:
115 #if IMPELLER_ENABLE_VULKAN
116 return PlaygroundImplVK::IsVulkanDriverPresent();
117 #else // IMPELLER_ENABLE_VULKAN
118 return false;
119 #endif // IMPELLER_ENABLE_VULKAN
120 }
121 FML_UNREACHABLE();
122 }
123
124 void Playground::SetupContext(PlaygroundBackend backend,
125 const PlaygroundSwitches& switches) {
126 FML_CHECK(SupportsBackend(backend));
127
128 impl_ = PlaygroundImpl::Create(backend, switches);
129 if (!impl_) {
130 FML_LOG(WARNING) << "PlaygroundImpl::Create failed.";
131 return;
132 }
133
134 context_ = impl_->GetContext();
135 }
136
137 void Playground::SetupWindow() {
138 if (!context_) {
139 FML_LOG(WARNING) << "Asked to set up a window with no context (call "
140 "SetupContext first).";
141 return;
142 }
143 auto renderer = std::make_unique<Renderer>(context_);
144 if (!renderer->IsValid()) {
145 return;
146 }
147 renderer_ = std::move(renderer);
148
149 start_time_ = fml::TimePoint::Now().ToEpochDelta();
150 }
151
152 bool Playground::IsPlaygroundEnabled() const {
153 return switches_.enable_playground;
154 }
155
156 void Playground::TeardownWindow() {
157 if (context_) {
158 context_->Shutdown();
159 }
160 context_.reset();
161 renderer_.reset();
162 impl_.reset();
163 }
164
165 static std::atomic_bool gShouldOpenNewPlaygrounds = true;
166
167 bool Playground::ShouldOpenNewPlaygrounds() {
168 return gShouldOpenNewPlaygrounds;
169 }
170
171 static void PlaygroundKeyCallback(GLFWwindow* window,
172 int key,
173 int scancode,
174 int action,
175 int mods) {
176 if ((key == GLFW_KEY_ESCAPE) && action == GLFW_RELEASE) {
177 if (mods & (GLFW_MOD_CONTROL | GLFW_MOD_SUPER | GLFW_MOD_SHIFT)) {
178 gShouldOpenNewPlaygrounds = false;
179 }
180 ::glfwSetWindowShouldClose(window, GLFW_TRUE);
181 }
182 }
183
184 Point Playground::GetCursorPosition() const {
185 return cursor_position_;
186 }
187
188 ISize Playground::GetWindowSize() const {
189 return window_size_;
190 }
191
192 Point Playground::GetContentScale() const {
193 return impl_->GetContentScale();
194 }
195
196 Scalar Playground::GetSecondsElapsed() const {
197 return (fml::TimePoint::Now().ToEpochDelta() - start_time_).ToSecondsF();
198 }
199
200 void Playground::SetCursorPosition(Point pos) {
201 cursor_position_ = pos;
202 }
203
204 bool Playground::OpenPlaygroundHere(
205 const Renderer::RenderCallback& render_callback) {
206 if (!switches_.enable_playground) {
207 return true;
208 }
209
210 if (!render_callback) {
211 return true;
212 }
213
214 if (!renderer_ || !renderer_->IsValid()) {
215 return false;
216 }
217
218 IMGUI_CHECKVERSION();
219 ImGui::CreateContext();
220 fml::ScopedCleanupClosure destroy_imgui_context(
221 []() { ImGui::DestroyContext(); });
222 ImGui::StyleColorsDark();
223
224 auto& io = ImGui::GetIO();
225 io.IniFilename = nullptr;
226 io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
227 io.ConfigWindowsResizeFromEdges = true;
228
229 auto window = reinterpret_cast<GLFWwindow*>(impl_->GetWindowHandle());
230 if (!window) {
231 return false;
232 }
233 ::glfwSetWindowTitle(window, GetWindowTitle().c_str());
234 ::glfwSetWindowUserPointer(window, this);
235 ::glfwSetWindowSizeCallback(
236 window, [](GLFWwindow* window, int width, int height) -> void {
237 auto playground =
238 reinterpret_cast<Playground*>(::glfwGetWindowUserPointer(window));
239 if (!playground) {
240 return;
241 }
242 playground->SetWindowSize(ISize{width, height}.Max({}));
243 });
244 ::glfwSetKeyCallback(window, &PlaygroundKeyCallback);
245 ::glfwSetCursorPosCallback(window, [](GLFWwindow* window, double x,
246 double y) {
247 reinterpret_cast<Playground*>(::glfwGetWindowUserPointer(window))
248 ->SetCursorPosition({static_cast<Scalar>(x), static_cast<Scalar>(y)});
249 });
250
251 ImGui_ImplGlfw_InitForOther(window, true);
252 fml::ScopedCleanupClosure shutdown_imgui([]() { ImGui_ImplGlfw_Shutdown(); });
253
254 ImGui_ImplImpeller_Init(renderer_->GetContext());
255 fml::ScopedCleanupClosure shutdown_imgui_impeller(
256 []() { ImGui_ImplImpeller_Shutdown(); });
257
258 ImGui::SetNextWindowPos({10, 10});
259
260 ::glfwSetWindowSize(window, GetWindowSize().width, GetWindowSize().height);
261 ::glfwSetWindowPos(window, 200, 100);
262 ::glfwShowWindow(window);
263
264 while (true) {
265 #if FML_OS_MACOSX
266 fml::ScopedNSAutoreleasePool pool;
267 #endif
268 ::glfwPollEvents();
269
270 if (::glfwWindowShouldClose(window)) {
271 return true;
272 }
273
274 ImGui_ImplGlfw_NewFrame();
275
276 Renderer::RenderCallback wrapped_callback =
277 [render_callback,
278 &renderer = renderer_](RenderTarget& render_target) -> bool {
279 ImGui::NewFrame();
280 ImGui::DockSpaceOverViewport(ImGui::GetMainViewport(),
281 ImGuiDockNodeFlags_PassthruCentralNode);
282 bool result = render_callback(render_target);
283 ImGui::Render();
284
285 // Render ImGui overlay.
286 {
287 auto buffer = renderer->GetContext()->CreateCommandBuffer();
288 if (!buffer) {
289 return false;
290 }
291 buffer->SetLabel("ImGui Command Buffer");
292
293 if (render_target.GetColorAttachments().empty()) {
294 return false;
295 }
296
297 auto color0 = render_target.GetColorAttachments().find(0)->second;
298 color0.load_action = LoadAction::kLoad;
299 if (color0.resolve_texture) {
300 color0.texture = color0.resolve_texture;
301 color0.resolve_texture = nullptr;
302 color0.store_action = StoreAction::kStore;
303 }
304 render_target.SetColorAttachment(color0, 0);
305
306 render_target.SetStencilAttachment(std::nullopt);
307 render_target.SetDepthAttachment(std::nullopt);
308
309 auto pass = buffer->CreateRenderPass(render_target);
310 if (!pass) {
311 return false;
312 }
313 pass->SetLabel("ImGui Render Pass");
314
315 ImGui_ImplImpeller_RenderDrawData(ImGui::GetDrawData(), *pass);
316
317 pass->EncodeCommands();
318 if (!renderer->GetContext()->GetCommandQueue()->Submit({buffer}).ok()) {
319 return false;
320 }
321 }
322
323 return result;
324 };
325
326 if (!renderer_->Render(impl_->AcquireSurfaceFrame(renderer_->GetContext()),
327 wrapped_callback)) {
328 VALIDATION_LOG << "Could not render into the surface.";
329 return false;
330 }
331
332 if (!ShouldKeepRendering()) {
333 break;
334 }
335 }
336
337 ::glfwHideWindow(window);
338
339 return true;
340 }
341
342 bool Playground::OpenPlaygroundHere(SinglePassCallback pass_callback) {
343 return OpenPlaygroundHere(
344 [context = GetContext(), &pass_callback](RenderTarget& render_target) {
345 auto buffer = context->CreateCommandBuffer();
346 if (!buffer) {
347 return false;
348 }
349 buffer->SetLabel("Playground Command Buffer");
350
351 auto pass = buffer->CreateRenderPass(render_target);
352 if (!pass) {
353 return false;
354 }
355 pass->SetLabel("Playground Render Pass");
356
357 if (!pass_callback(*pass)) {
358 return false;
359 }
360
361 pass->EncodeCommands();
362 if (!context->GetCommandQueue()->Submit({buffer}).ok()) {
363 return false;
364 }
365 return true;
366 });
367 }
368
369 std::shared_ptr<CompressedImage> Playground::LoadFixtureImageCompressed(
370 std::shared_ptr<fml::Mapping> mapping) {
371 auto compressed_image = CompressedImageSkia::Create(std::move(mapping));
372 if (!compressed_image) {
373 VALIDATION_LOG << "Could not create compressed image.";
374 return nullptr;
375 }
376
377 return compressed_image;
378 }
379
380 std::optional<DecompressedImage> Playground::DecodeImageRGBA(
381 const std::shared_ptr<CompressedImage>& compressed) {
382 if (compressed == nullptr) {
383 return std::nullopt;
384 }
385 // The decoded image is immediately converted into RGBA as that format is
386 // known to be supported everywhere. For image sources that don't need 32
387 // bit pixel strides, this is overkill. Since this is a test fixture we
388 // aren't necessarily trying to eke out memory savings here and instead
389 // favor simplicity.
390 auto image = compressed->Decode().ConvertToRGBA();
391 if (!image.IsValid()) {
392 VALIDATION_LOG << "Could not decode image.";
393 return std::nullopt;
394 }
395
396 return image;
397 }
398
399 static std::shared_ptr<Texture> CreateTextureForDecompressedImage(
400 const std::shared_ptr<Context>& context,
401 DecompressedImage& decompressed_image,
402 bool enable_mipmapping) {
403 auto texture_descriptor = TextureDescriptor{};
404 texture_descriptor.storage_mode = StorageMode::kHostVisible;
405 texture_descriptor.format = PixelFormat::kR8G8B8A8UNormInt;
406 texture_descriptor.size = decompressed_image.GetSize();
407 texture_descriptor.mip_count =
408 enable_mipmapping ? decompressed_image.GetSize().MipCount() : 1u;
409
410 auto texture =
411 context->GetResourceAllocator()->CreateTexture(texture_descriptor);
412 if (!texture) {
413 VALIDATION_LOG << "Could not allocate texture for fixture.";
414 return nullptr;
415 }
416
417 auto command_buffer = context->CreateCommandBuffer();
418 if (!command_buffer) {
419 FML_DLOG(ERROR) << "Could not create command buffer for mipmap generation.";
420 return nullptr;
421 }
422 command_buffer->SetLabel("Mipmap Command Buffer");
423
424 auto blit_pass = command_buffer->CreateBlitPass();
425 auto buffer_view = DeviceBuffer::AsBufferView(
426 context->GetResourceAllocator()->CreateBufferWithCopy(
427 *decompressed_image.GetAllocation()));
428 blit_pass->AddCopy(buffer_view, texture);
429 if (enable_mipmapping) {
430 blit_pass->SetLabel("Mipmap Blit Pass");
431 blit_pass->GenerateMipmap(texture);
432 }
433 blit_pass->EncodeCommands(context->GetResourceAllocator());
434 if (!context->GetCommandQueue()->Submit({command_buffer}).ok()) {
435 FML_DLOG(ERROR) << "Failed to submit blit pass command buffer.";
436 return nullptr;
437 }
438 return texture;
439 }
440
441 std::shared_ptr<Texture> Playground::CreateTextureForMapping(
442 const std::shared_ptr<Context>& context,
443 std::shared_ptr<fml::Mapping> mapping,
444 bool enable_mipmapping) {
445 auto image = Playground::DecodeImageRGBA(
446 Playground::LoadFixtureImageCompressed(std::move(mapping)));
447 if (!image.has_value()) {
448 return nullptr;
449 }
450 return CreateTextureForDecompressedImage(context, image.value(),
451 enable_mipmapping);
452 }
453
454 std::shared_ptr<Texture> Playground::CreateTextureForFixture(
455 const char* fixture_name,
456 bool enable_mipmapping) const {
457 auto texture = CreateTextureForMapping(renderer_->GetContext(),
458 OpenAssetAsMapping(fixture_name),
459 enable_mipmapping);
460 if (texture == nullptr) {
461 return nullptr;
462 }
463 texture->SetLabel(fixture_name);
464 return texture;
465 }
466
467 std::shared_ptr<Texture> Playground::CreateTextureCubeForFixture(
468 std::array<const char*, 6> fixture_names) const {
469 std::array<DecompressedImage, 6> images;
470 for (size_t i = 0; i < fixture_names.size(); i++) {
471 auto image = DecodeImageRGBA(
472 LoadFixtureImageCompressed(OpenAssetAsMapping(fixture_names[i])));
473 if (!image.has_value()) {
474 return nullptr;
475 }
476 images[i] = image.value();
477 }
478
479 auto texture_descriptor = TextureDescriptor{};
480 texture_descriptor.storage_mode = StorageMode::kHostVisible;
481 texture_descriptor.type = TextureType::kTextureCube;
482 texture_descriptor.format = PixelFormat::kR8G8B8A8UNormInt;
483 texture_descriptor.size = images[0].GetSize();
484 texture_descriptor.mip_count = 1u;
485
486 auto texture = renderer_->GetContext()->GetResourceAllocator()->CreateTexture(
487 texture_descriptor);
488 if (!texture) {
489 VALIDATION_LOG << "Could not allocate texture cube.";
490 return nullptr;
491 }
492 texture->SetLabel("Texture cube");
493
494 auto cmd_buffer = renderer_->GetContext()->CreateCommandBuffer();
495 auto blit_pass = cmd_buffer->CreateBlitPass();
496 for (size_t i = 0; i < fixture_names.size(); i++) {
497 auto device_buffer =
498 renderer_->GetContext()->GetResourceAllocator()->CreateBufferWithCopy(
499 *images[i].GetAllocation());
500 blit_pass->AddCopy(DeviceBuffer::AsBufferView(device_buffer), texture, {},
501 "", /*slice=*/i);
502 }
503
504 if (!blit_pass->EncodeCommands(
505 renderer_->GetContext()->GetResourceAllocator()) ||
506 !renderer_->GetContext()
507 ->GetCommandQueue()
508 ->Submit({std::move(cmd_buffer)})
509 .ok()) {
510 VALIDATION_LOG << "Could not upload texture to device memory.";
511 return nullptr;
512 }
513
514 return texture;
515 }
516
517 void Playground::SetWindowSize(ISize size) {
518 window_size_ = size;
519 }
520
521 bool Playground::ShouldKeepRendering() const {
522 return true;
523 }
524
525 fml::Status Playground::SetCapabilities(
526 const std::shared_ptr<Capabilities>& capabilities) {
527 return impl_->SetCapabilities(capabilities);
528 }
529
530 bool Playground::WillRenderSomething() const {
531 return switches_.enable_playground;
532 }
533
534 } // namespace impeller
impeller::DecompressedImage
Definition: decompressed_image.h:15
impeller::DeviceBuffer::AsBufferView
static BufferView AsBufferView(std::shared_ptr< DeviceBuffer > buffer)
Create a buffer view of this entire buffer.
Definition: device_buffer.cc:18
impeller::Playground::ShouldOpenNewPlaygrounds
static bool ShouldOpenNewPlaygrounds()
Definition: playground.cc:167
impeller::PlaygroundImplVK::IsVulkanDriverPresent
static bool IsVulkanDriverPresent()
Definition: playground_impl_vk.cc:219
impeller::Playground::CreateTextureCubeForFixture
std::shared_ptr< Texture > CreateTextureCubeForFixture(std::array< const char *, 6 > fixture_names) const
Definition: playground.cc:467
impeller::LoadAction::kLoad
@ kLoad
impeller::PlaygroundBackend::kVulkan
@ kVulkan
impeller::CreateTextureForDecompressedImage
static std::shared_ptr< Texture > CreateTextureForDecompressedImage(const std::shared_ptr< Context > &context, DecompressedImage &decompressed_image, bool enable_mipmapping)
Definition: playground.cc:399
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::Playground::WillRenderSomething
bool WillRenderSomething() const
Definition: playground.cc:530
impeller::Playground::ShouldKeepRendering
virtual bool ShouldKeepRendering() const
Definition: playground.cc:521
impeller::Renderer::RenderCallback
std::function< bool(RenderTarget &render_target)> RenderCallback
Definition: renderer.h:23
impeller::Playground::DecodeImageRGBA
static std::optional< DecompressedImage > DecodeImageRGBA(const std::shared_ptr< CompressedImage > &compressed)
Definition: playground.cc:380
impeller::Playground::GetSecondsElapsed
Scalar GetSecondsElapsed() const
Get the amount of time elapsed from the start of the playground's execution.
Definition: playground.cc:196
impeller::Playground::GetWindowSize
ISize GetWindowSize() const
Definition: playground.cc:188
impeller::PlaygroundBackend::kMetal
@ kMetal
impeller::PixelFormat::kR8G8B8A8UNormInt
@ kR8G8B8A8UNormInt
impeller::PlaygroundKeyCallback
static void PlaygroundKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
Definition: playground.cc:171
impeller::PlaygroundBackendToString
std::string PlaygroundBackendToString(PlaygroundBackend backend)
Definition: playground.cc:45
formats.h
playground.h
impeller::CompressedImageSkia::Create
static std::shared_ptr< CompressedImage > Create(std::shared_ptr< const fml::Mapping > allocation)
Definition: compressed_image_skia.cc:18
impeller::PlaygroundBackend
PlaygroundBackend
Definition: playground.h:27
buffer_view
BufferView buffer_view
Definition: blit_command_gles.cc:127
impeller::StorageMode::kHostVisible
@ kHostVisible
impeller::Playground::MakeContext
std::shared_ptr< Context > MakeContext() const
Definition: playground.cc:94
validation.h
impeller::PlaygroundSwitches::use_swiftshader
bool use_swiftshader
Definition: switches.h:27
impeller::TSize
Definition: size.h:19
render_pass.h
runtime_stage.h
impeller::Playground
Definition: playground.h:48
impeller::gShouldOpenNewPlaygrounds
static std::atomic_bool gShouldOpenNewPlaygrounds
Definition: playground.cc:165
impeller::Playground::SetupWindow
void SetupWindow()
Definition: playground.cc:137
impeller::TSize::Max
constexpr TSize Max(const TSize &o) const
Definition: size.h:81
impeller::InitializeGLFWOnce
static void InitializeGLFWOnce()
Definition: playground.cc:57
impeller::Playground::switches_
const PlaygroundSwitches switches_
Definition: playground.h:118
impeller::TextureType::kTextureCube
@ kTextureCube
impeller::RenderTarget
Definition: render_target.h:38
impeller::StoreAction::kStore
@ kStore
impeller::Playground::IsPlaygroundEnabled
bool IsPlaygroundEnabled() const
Definition: playground.cc:152
compressed_image_skia.h
impeller::Playground::SinglePassCallback
std::function< bool(RenderPass &pass)> SinglePassCallback
Definition: playground.h:50
impeller::PlaygroundImpl::Create
static std::unique_ptr< PlaygroundImpl > Create(PlaygroundBackend backend, PlaygroundSwitches switches)
Definition: playground_impl.cc:25
impeller::Playground::SetupContext
void SetupContext(PlaygroundBackend backend, const PlaygroundSwitches &switches)
Definition: playground.cc:124
ImGui_ImplImpeller_Shutdown
void ImGui_ImplImpeller_Shutdown()
Definition: imgui_impl_impeller.cc:119
swiftshader_utilities.h
decompressed_image.h
impeller::Playground::~Playground
virtual ~Playground()
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:73
command_buffer.h
allocator.h
ImGui_ImplImpeller_RenderDrawData
void ImGui_ImplImpeller_RenderDrawData(ImDrawData *draw_data, impeller::RenderPass &render_pass)
Definition: imgui_impl_impeller.cc:126
impeller::PlaygroundBackend::kOpenGLES
@ kOpenGLES
impeller::Playground::CreateTextureForMapping
static std::shared_ptr< Texture > CreateTextureForMapping(const std::shared_ptr< Context > &context, std::shared_ptr< fml::Mapping > mapping, bool enable_mipmapping=false)
Definition: playground.cc:441
playground_impl_vk.h
impeller::Playground::GetContentScale
Point GetContentScale() const
Definition: playground.cc:192
impeller::PlaygroundSwitches
Definition: switches.h:15
impeller::Playground::LoadFixtureImageCompressed
static std::shared_ptr< CompressedImage > LoadFixtureImageCompressed(std::shared_ptr< fml::Mapping > mapping)
Definition: playground.cc:369
impeller::Playground::GetWindowTitle
virtual std::string GetWindowTitle() const =0
impeller::DecompressedImage::GetAllocation
const std::shared_ptr< const fml::Mapping > & GetAllocation() const
Definition: decompressed_image.cc:41
impeller::TPoint< Scalar >
impeller::Playground::OpenAssetAsMapping
virtual std::unique_ptr< fml::Mapping > OpenAssetAsMapping(std::string asset_name) const =0
impeller::Playground::SetCapabilities
fml::Status SetCapabilities(const std::shared_ptr< Capabilities > &capabilities)
Definition: playground.cc:525
impeller::Playground::GetCursorPosition
Point GetCursorPosition() const
Definition: playground.cc:184
impeller::SetupSwiftshaderOnce
void SetupSwiftshaderOnce(bool use_swiftshader)
Find and setup the installable client driver for a locally built SwiftShader at known paths....
Definition: swiftshader_utilities.cc:54
impeller::Playground::SupportsBackend
static bool SupportsBackend(PlaygroundBackend backend)
Definition: playground.cc:100
context.h
impeller::Playground::OpenPlaygroundHere
bool OpenPlaygroundHere(const Renderer::RenderCallback &render_callback)
Definition: playground.cc:204
impeller::TextureDescriptor::storage_mode
StorageMode storage_mode
Definition: texture_descriptor.h:39
ImGui_ImplImpeller_Init
bool ImGui_ImplImpeller_Init(const std::shared_ptr< impeller::Context > &context)
Definition: imgui_impl_impeller.cc:56
impeller::TextureDescriptor
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
Definition: texture_descriptor.h:38
impeller::Playground::TeardownWindow
void TeardownWindow()
Definition: playground.cc:156
impeller::Playground::Playground
Playground(PlaygroundSwitches switches)
Definition: playground.cc:83
impeller::Playground::GetContext
std::shared_ptr< Context > GetContext() const
Definition: playground.cc:90
impeller::TSize::MipCount
constexpr size_t MipCount() const
Definition: size.h:115
playground_impl.h
renderer.h
impeller
Definition: aiks_blend_unittests.cc:18
imgui_impl_impeller.h
impeller::Playground::SetWindowSize
void SetWindowSize(ISize size)
Definition: playground.cc:517
impeller::PlaygroundSwitches::enable_playground
bool enable_playground
Definition: switches.h:16
impeller::DecompressedImage::GetSize
const ISize & GetSize() const
Definition: decompressed_image.cc:33
compressed_image.h
impeller::Playground::CreateTextureForFixture
std::shared_ptr< Texture > CreateTextureForFixture(const char *fixture_name, bool enable_mipmapping=false) const
Definition: playground.cc:454