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 "flutter/testing/test_metal_surface.h"
6
7#if TESTING_ENABLE_METAL
8#include "flutter/testing/test_metal_surface_impl.h"
9#endif // TESTING_ENABLE_METAL
10
11namespace flutter {
12
13bool TestMetalSurface::PlatformSupportsMetal() {
14#if TESTING_ENABLE_METAL
15 return true;
16#else // TESTING_ENABLE_METAL
17 return false;
18#endif // TESTING_ENABLE_METAL
19}
20
21std::unique_ptr<TestMetalSurface> TestMetalSurface::Create(
22 SkISize surface_size) {
23#if TESTING_ENABLE_METAL
24 return std::make_unique<TestMetalSurfaceImpl>(surface_size);
25#else // TESTING_ENABLE_METAL
26 return nullptr;
27#endif // TESTING_ENABLE_METAL
28}
29
30TestMetalSurface::TestMetalSurface() = default;
31
32TestMetalSurface::~TestMetalSurface() = default;
33
34bool TestMetalSurface::IsValid() const {
35 return impl_ ? impl_->IsValid() : false;
36}
37
38sk_sp<GrDirectContext> TestMetalSurface::GetGrContext() const {
39 return impl_ ? impl_->GetGrContext() : nullptr;
40}
41
42sk_sp<SkSurface> TestMetalSurface::GetSurface() const {
43 return impl_ ? impl_->GetSurface() : nullptr;
44}
45
46} // namespace flutter
47