gpu_rasterizer.h 1.5 KB
Newer Older
1 2 3 4
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
#ifndef SHELL_GPU_DIRECT_GPU_RASTERIZER_H_
#define SHELL_GPU_DIRECT_GPU_RASTERIZER_H_
7

8
#include "flutter/flow/compositor_context.h"
9
#include "flutter/shell/common/rasterizer.h"
10
#include "flutter/shell/gpu/gpu_canvas.h"
11 12
#include "lib/ftl/memory/weak_ptr.h"
#include "lib/ftl/synchronization/waitable_event.h"
13 14 15

namespace shell {

16
class GPURasterizer : public Rasterizer {
17
 public:
18
  GPURasterizer();
19

20
  ~GPURasterizer() override;
F
Florian Loitsch 已提交
21

22
  void Setup(PlatformView* platform_view,
23 24
             ftl::Closure continuation,
             ftl::AutoResetWaitableEvent* setup_completion_event) override;
25

26 27
  void Clear(SkColor color) override;

28 29
  void Teardown(
      ftl::AutoResetWaitableEvent* teardown_completion_event) override;
F
Florian Loitsch 已提交
30

31
  ftl::WeakPtr<Rasterizer> GetWeakRasterizerPtr() override;
32

33
  flow::LayerTree* GetLastLayerTree() override;
34

35 36
  void Draw(ftl::RefPtr<flutter::Pipeline<flow::LayerTree>> pipeline) override;

37
 private:
38
  std::unique_ptr<GPUCanvas> gpu_canvas_;
39
  flow::CompositorContext compositor_context_;
40
  std::unique_ptr<flow::LayerTree> last_layer_tree_;
41
  PlatformView* platform_view_;
42
  ftl::WeakPtrFactory<GPURasterizer> weak_factory_;
43

44 45 46
  FTL_WARN_UNUSED_RESULT
  bool Setup(PlatformView* platform_view);

47
  void DoDraw(std::unique_ptr<flow::LayerTree> tree);
48

49
  FTL_DISALLOW_COPY_AND_ASSIGN(GPURasterizer);
50 51 52 53
};

}  // namespace shell

54
#endif  // SHELL_GPU_DIRECT_GPU_RASTERIZER_H_