Flutter Engine
test_metal_surface.h
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 #ifndef FLUTTER_TESTING_TEST_METAL_SURFACE_H_
6 #define FLUTTER_TESTING_TEST_METAL_SURFACE_H_
7 
8 #include "flutter/fml/macros.h"
9 #include "third_party/skia/include/core/SkSize.h"
10 #include "third_party/skia/include/core/SkSurface.h"
11 #include "third_party/skia/include/gpu/GrDirectContext.h"
12 
13 namespace flutter {
14 
15 //------------------------------------------------------------------------------
16 /// @brief Creates a MTLTexture backed SkSurface and context that can be
17 /// used to render to in unit-tests.
18 ///
20  public:
21  static bool PlatformSupportsMetal();
22 
23  static std::unique_ptr<TestMetalSurface> Create(
24  SkISize surface_size = SkISize::MakeEmpty());
25 
26  virtual ~TestMetalSurface();
27 
28  virtual bool IsValid() const;
29 
30  virtual sk_sp<GrDirectContext> GetGrContext() const;
31 
32  virtual sk_sp<SkSurface> GetSurface() const;
33 
34  protected:
36 
37  private:
38  std::unique_ptr<TestMetalSurface> impl_;
39 
40  TestMetalSurface(std::unique_ptr<TestMetalSurface> impl);
41 
42  FML_DISALLOW_COPY_AND_ASSIGN(TestMetalSurface);
43 };
44 
45 } // namespace flutter
46 
47 #endif // FLUTTER_TESTING_TEST_METAL_SURFACE_H_
virtual bool IsValid() const
static std::unique_ptr< TestMetalSurface > Create(SkISize surface_size=SkISize::MakeEmpty())
virtual sk_sp< SkSurface > GetSurface() const
virtual sk_sp< GrDirectContext > GetGrContext() const
Creates a MTLTexture backed SkSurface and context that can be used to render to in unit-tests...