forked from flutter-tizen/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
embedder_external_texture_resolver.cc
85 lines (70 loc) · 2.22 KB
/
embedder_external_texture_resolver.cc
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// 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.
#include "flutter/shell/platform/embedder/embedder_external_texture_resolver.h"
#include <memory>
#include <utility>
namespace flutter {
#ifdef SHELL_ENABLE_GL
EmbedderExternalTextureResolver::EmbedderExternalTextureResolver(
EmbedderExternalTextureGL::ExternalTextureCallback gl_callback)
: gl_callback_(std::move(gl_callback)) {}
#endif
#ifdef SHELL_ENABLE_METAL
EmbedderExternalTextureResolver::EmbedderExternalTextureResolver(
EmbedderExternalTextureMetal::ExternalTextureCallback metal_callback)
: metal_callback_(std::move(metal_callback)) {}
#endif
std::unique_ptr<Texture>
EmbedderExternalTextureResolver::ResolveExternalTexture(
int64_t texture_id,
FlutterTextureType type) {
#ifdef SHELL_ENABLE_GL
if (gl_callback_) {
if (type == FlutterTextureType::kFlutterGpuSurfaceTexture) {
return std::make_unique<EmbedderExternalTextureGLImpellerSurface>(
texture_id, gl_callback_);
} else {
return std::make_unique<EmbedderExternalTextureGLImpellerPixelBuffer>(
texture_id, gl_callback_);
}
}
#endif
#ifdef SHELL_ENABLE_METAL
if (metal_callback_) {
return std::make_unique<EmbedderExternalTextureMetal>(texture_id,
metal_callback_);
}
#endif
return nullptr;
}
std::unique_ptr<Texture>
EmbedderExternalTextureResolver::ResolveExternalTexture(int64_t texture_id) {
#ifdef SHELL_ENABLE_GL
if (gl_callback_) {
return std::make_unique<EmbedderExternalTextureSkiaGL>(texture_id,
gl_callback_);
}
#endif
#ifdef SHELL_ENABLE_METAL
if (metal_callback_) {
return std::make_unique<EmbedderExternalTextureMetal>(texture_id,
metal_callback_);
}
#endif
return nullptr;
}
bool EmbedderExternalTextureResolver::SupportsExternalTextures() {
#ifdef SHELL_ENABLE_GL
if (gl_callback_) {
return true;
}
#endif
#ifdef SHELL_ENABLE_METAL
if (metal_callback_) {
return true;
}
#endif
return false;
}
} // namespace flutter