1 // Copyright 2019 The Chromium 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 #ifndef COMPONENTS_VIZ_SERVICE_DISPLAY_EMBEDDER_SKIA_OUTPUT_DEVICE_DAWN_H_ 6 #define COMPONENTS_VIZ_SERVICE_DISPLAY_EMBEDDER_SKIA_OUTPUT_DEVICE_DAWN_H_ 7 8 #include <dawn/dawn_wsi.h> 9 #include <dawn/webgpu.h> 10 #include <dawn_native/DawnNative.h> 11 12 #include "components/viz/service/display_embedder/skia_output_device.h" 13 #include "third_party/skia/include/core/SkColorSpace.h" 14 #include "third_party/skia/include/core/SkImageInfo.h" 15 #include "third_party/skia/include/gpu/GrBackendSurface.h" 16 #include "ui/gfx/native_widget_types.h" 17 18 namespace viz { 19 20 class DawnContextProvider; 21 22 class SkiaOutputDeviceDawn : public SkiaOutputDevice { 23 public: 24 SkiaOutputDeviceDawn( 25 DawnContextProvider* context_provider, 26 gfx::AcceleratedWidget widget, 27 gfx::SurfaceOrigin origin, 28 gpu::MemoryTracker* memory_tracker, 29 DidSwapBufferCompleteCallback did_swap_buffer_complete_callback); 30 ~SkiaOutputDeviceDawn() override; 31 32 // SkiaOutputDevice implementation: 33 bool Reshape(const gfx::Size& size, 34 float device_scale_factor, 35 const gfx::ColorSpace& color_space, 36 gfx::BufferFormat format, 37 gfx::OverlayTransform transform) override; 38 void SwapBuffers(BufferPresentedCallback feedback, 39 std::vector<ui::LatencyInfo> latency_info) override; 40 SkSurface* BeginPaint( 41 std::vector<GrBackendSemaphore>* end_semaphores) override; 42 void EndPaint() override; 43 44 private: 45 // Create a platform-specific swapchain implementation. 46 void CreateSwapChainImplementation(); 47 48 DawnContextProvider* const context_provider_; 49 gfx::AcceleratedWidget widget_; 50 DawnSwapChainImplementation swap_chain_implementation_; 51 wgpu::SwapChain swap_chain_; 52 wgpu::Texture texture_; 53 sk_sp<SkSurface> sk_surface_; 54 55 gfx::Size size_; 56 sk_sp<SkColorSpace> sk_color_space_; 57 GrBackendTexture backend_texture_; 58 59 DISALLOW_COPY_AND_ASSIGN(SkiaOutputDeviceDawn); 60 }; 61 62 } // namespace viz 63 64 #endif // COMPONENTS_VIZ_SERVICE_DISPLAY_EMBEDDER_SKIA_OUTPUT_DEVICE_DAWN_H_ 65