// Copyright 2018 The Chromium 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 GPU_VULKAN_DEMO_VULKAN_DEMO_H_ #define GPU_VULKAN_DEMO_VULKAN_DEMO_H_ #include #include "base/memory/scoped_refptr.h" #include "gpu/vulkan/vulkan_swap_chain.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/skia/include/core/SkRefCnt.h" #include "ui/gfx/geometry/size.h" #include "ui/platform_window/platform_window.h" #include "ui/platform_window/platform_window_delegate.h" class SkCanvas; class SkSurface; namespace base { class RunLoop; } namespace viz { class VulkanContextProvider; } namespace ui { class PlatformEventSource; } // namespace ui namespace gpu { class VulkanImplementation; class VulkanSurface; class VulkanDemo : public ui::PlatformWindowDelegate { public: VulkanDemo(); ~VulkanDemo() override; void Initialize(); void Destroy(); void Run(); private: // ui::PlatformWindowDelegate: void OnBoundsChanged(const BoundsChange& change) override; void OnDamageRect(const gfx::Rect& damaged_region) override {} void DispatchEvent(ui::Event* event) override {} void OnCloseRequest() override; void OnClosed() override {} void OnWindowStateChanged(ui::PlatformWindowState old_state, ui::PlatformWindowState new_state) override {} void OnLostCapture() override {} void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) override; void OnWillDestroyAcceleratedWidget() override {} void OnAcceleratedWidgetDestroyed() override {} void OnActivationChanged(bool active) override {} void OnMouseEnter() override {} void CreateSkSurface(); void Draw(SkCanvas* canvas, float fraction); void RenderFrame(); std::unique_ptr vulkan_implementation_; scoped_refptr vulkan_context_provider_; gfx::AcceleratedWidget accelerated_widget_ = gfx::kNullAcceleratedWidget; std::unique_ptr event_source_; std::unique_ptr window_; std::unique_ptr vulkan_surface_; absl::optional scoped_write_; sk_sp sk_surface_; std::vector> sk_surfaces_; float rotation_angle_ = 0; base::RunLoop* run_loop_ = nullptr; bool is_running_ = false; }; } // namespace gpu #endif // GPU_VULKAN_DEMO_VULKAN_DEMO_H_