Flutter Engine
texture.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_FLOW_TEXTURE_H_
6 #define FLUTTER_FLOW_TEXTURE_H_
7 
8 #include <map>
9 
10 #include "flutter/fml/macros.h"
11 #include "flutter/fml/synchronization/waitable_event.h"
12 #include "third_party/skia/include/core/SkCanvas.h"
13 
14 class GrDirectContext;
15 
16 namespace flutter {
17 
18 class Texture {
19  public:
20  Texture(int64_t id); // Called from UI or raster thread.
21  virtual ~Texture(); // Called from raster thread.
22 
23  // Called from raster thread.
24  virtual void Paint(SkCanvas& canvas,
25  const SkRect& bounds,
26  bool freeze,
27  GrDirectContext* context,
28  SkFilterQuality quality) = 0;
29 
30  // Called from raster thread.
31  virtual void OnGrContextCreated() = 0;
32 
33  // Called from raster thread.
34  virtual void OnGrContextDestroyed() = 0;
35 
36  // Called on raster thread.
37  virtual void MarkNewFrameAvailable() = 0;
38 
39  // Called on raster thread.
40  virtual void OnTextureUnregistered() = 0;
41 
42  int64_t Id() { return id_; }
43 
44  private:
45  int64_t id_;
46 
47  FML_DISALLOW_COPY_AND_ASSIGN(Texture);
48 };
49 
51  public:
53 
54  // Called from raster thread.
55  void RegisterTexture(std::shared_ptr<Texture> texture);
56 
57  // Called from raster thread.
58  void UnregisterTexture(int64_t id);
59 
60  // Called from raster thread.
61  std::shared_ptr<Texture> GetTexture(int64_t id);
62 
63  // Called from raster thread.
64  void OnGrContextCreated();
65 
66  // Called from raster thread.
67  void OnGrContextDestroyed();
68 
69  private:
70  std::map<int64_t, std::shared_ptr<Texture>> mapping_;
71 
73 };
74 
75 } // namespace flutter
76 
77 #endif // FLUTTER_FLOW_TEXTURE_H_
int64_t Id()
Definition: texture.h:42
static void UnregisterTexture(JNIEnv *env, jobject jcaller, jlong shell_holder, jlong texture_id)
virtual void OnTextureUnregistered()=0
virtual void OnGrContextDestroyed()=0
virtual void MarkNewFrameAvailable()=0
virtual ~Texture()
virtual void OnGrContextCreated()=0
static void RegisterTexture(JNIEnv *env, jobject jcaller, jlong shell_holder, jlong texture_id, jobject surface_texture)
virtual void Paint(SkCanvas &canvas, const SkRect &bounds, bool freeze, GrDirectContext *context, SkFilterQuality quality)=0
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: macros.h:27
Texture(int64_t id)
Definition: texture.cc:9