Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
dl_test_surface_provider_skia_metal.mm
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
11
12#include "third_party/skia/include/core/SkSurface.h"
13
14namespace flutter {
15namespace testing {
16
17std::unique_ptr<DlSurfaceProvider> DlSurfaceProvider::CreateSkiaMetal() {
18 return std::make_unique<DlSurfaceProviderSkiaMetal>();
19}
20
22 public:
23 explicit DlMetalSurfaceInstance(std::unique_ptr<TestMetalSurface> metal_surface)
24 : DlSurfaceInstanceSkiaBase(), metal_surface_(std::move(metal_surface)) {}
26
27 protected:
28 sk_sp<SkSurface> GetSurface() const override { return metal_surface_->GetSurface(); }
29
30 private:
31 std::unique_ptr<TestMetalSurface> metal_surface_;
32};
33
35 size_t height,
36 PixelFormat format) {
37 if (format != kN32Premul) {
38 return false;
39 }
40 metal_context_ = std::make_unique<TestMetalContext>();
41 metal_surface_ = MakeOffscreenSurface(width, height, format);
42 return true;
43}
44
45std::shared_ptr<DlSurfaceInstance> DlSurfaceProviderSkiaMetal::GetPrimarySurface() const {
46 if (!metal_surface_) {
47 return nullptr;
48 }
49 return metal_surface_;
50}
51
52std::unique_ptr<DlSurfaceInstance> DlSurfaceProviderSkiaMetal::MakeOffscreenSurface(
53 size_t width,
54 size_t height,
55 PixelFormat format) const {
56 auto surface = TestMetalSurface::Create(*metal_context_, DlISize(width, height));
57 surface->GetSurface()->getCanvas()->clear(SK_ColorTRANSPARENT);
58 return std::make_unique<DlMetalSurfaceInstance>(std::move(surface));
59}
60
61} // namespace testing
62} // namespace flutter
DlMetalSurfaceInstance(std::unique_ptr< TestMetalSurface > metal_surface)
std::unique_ptr< DlSurfaceInstance > MakeOffscreenSurface(size_t width, size_t height, PixelFormat format) const override
bool InitializeSurface(size_t width, size_t height, PixelFormat format) override
std::shared_ptr< DlSurfaceInstance > GetPrimarySurface() const override
static std::unique_ptr< TestMetalSurface > Create(const TestMetalContext &test_metal_context, DlISize surface_size=DlISize())
VkSurfaceKHR surface
Definition main.cc:65
uint32_t uint32_t * format
impeller::ISize32 DlISize
Definition ref_ptr.h:261
int32_t height
int32_t width