• 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_LIB_UI_PAINTING_SINGLE_FRAME_CODEC_H_
6 #define FLUTTER_LIB_UI_PAINTING_SINGLE_FRAME_CODEC_H_
7 
8 #include "flutter/fml/macros.h"
9 #include "flutter/lib/ui/painting/codec.h"
10 #include "flutter/lib/ui/painting/frame_info.h"
11 #include "flutter/lib/ui/painting/image_decoder.h"
12 
13 namespace flutter {
14 
15 class SingleFrameCodec : public Codec {
16  public:
17   SingleFrameCodec(ImageDecoder::ImageDescriptor descriptor);
18 
19   ~SingleFrameCodec() override;
20 
21   // |Codec|
22   int frameCount() const override;
23 
24   // |Codec|
25   int repetitionCount() const override;
26 
27   // |Codec|
28   Dart_Handle getNextFrame(Dart_Handle args) override;
29 
30   // |DartWrappable|
31   size_t GetAllocationSize() override;
32 
33  private:
34   enum class Status { kNew, kInProgress, kComplete };
35   Status status_;
36   ImageDecoder::ImageDescriptor descriptor_;
37   fml::RefPtr<FrameInfo> cached_frame_;
38   std::vector<DartPersistentValue> pending_callbacks_;
39 
40   FML_FRIEND_MAKE_REF_COUNTED(SingleFrameCodec);
41   FML_FRIEND_REF_COUNTED_THREAD_SAFE(SingleFrameCodec);
42 };
43 
44 }  // namespace flutter
45 
46 #endif  // FLUTTER_LIB_UI_PAINTING_SINGLE_FRAME_CODEC_H_
47