• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_SHELL_PLATFORM_EMBEDDER_EMBEDDER_EXTERNAL_TEXTURE_GL_H_
6 #define FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_EXTERNAL_TEXTURE_GL_H_
7 
8 #include "flutter/flow/texture.h"
9 #include "flutter/fml/macros.h"
10 #include "third_party/skia/include/core/SkImage.h"
11 #include "third_party/skia/include/core/SkSize.h"
12 
13 namespace flutter {
14 
15 class EmbedderExternalTextureGL : public flutter::Texture {
16  public:
17   using ExternalTextureCallback = std::function<
18       sk_sp<SkImage>(int64_t texture_identifier, GrContext*, const SkISize&)>;
19 
20   EmbedderExternalTextureGL(int64_t texture_identifier,
21                             ExternalTextureCallback callback);
22 
23   ~EmbedderExternalTextureGL();
24 
25  private:
26   ExternalTextureCallback external_texture_callback_;
27   sk_sp<SkImage> last_image_;
28 
29   // |flutter::Texture|
30   void Paint(SkCanvas& canvas,
31              const SkRect& bounds,
32              bool freeze,
33              GrContext* context) override;
34 
35   // |flutter::Texture|
36   void OnGrContextCreated() override;
37 
38   // |flutter::Texture|
39   void OnGrContextDestroyed() override;
40 
41   // |flutter::Texture|
42   void MarkNewFrameAvailable() override;
43 
44   FML_DISALLOW_COPY_AND_ASSIGN(EmbedderExternalTextureGL);
45 };
46 
47 }  // namespace flutter
48 
49 #endif  // FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_EXTERNAL_TEXTURE_GL_H_
50