forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_metal_context.h
51 lines (35 loc) · 1.23 KB
/
test_metal_context.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2013 The Flutter 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 FLUTTER_TESTING_TEST_METAL_CONTEXT_H_
#define FLUTTER_TESTING_TEST_METAL_CONTEXT_H_
#include <map>
#include <mutex>
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "third_party/skia/include/gpu/mtl/GrMtlTypes.h"
namespace flutter {
class TestMetalContext {
public:
struct TextureInfo {
int64_t texture_id;
void* texture;
};
TestMetalContext();
~TestMetalContext();
void* GetMetalDevice() const;
void* GetMetalCommandQueue() const;
sk_sp<GrDirectContext> GetSkiaContext() const;
/// Returns texture_id = -1 when texture creation fails.
TextureInfo CreateMetalTexture(const SkISize& size);
bool Present(int64_t texture_id);
TextureInfo GetTextureInfo(int64_t texture_id);
private:
void* device_;
void* command_queue_;
sk_sp<GrDirectContext> skia_context_;
std::mutex textures_mutex;
int64_t texture_id_ctr_ = 1; // guarded by textures_mutex
std::map<int64_t, sk_cf_obj<void*>> textures_; // guarded by textures_mutex
};
} // namespace flutter
#endif // FLUTTER_TESTING_TEST_METAL_CONTEXT_H_