surface.h 1.3 KB
Newer Older
1 2 3 4 5 6
// 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.

#pragma once

7
#include "flutter/flow/surface.h"
8 9 10 11 12 13
#include "flutter/fml/macros.h"
#include "flutter/fml/memory/weak_ptr.h"

namespace flutter_runner {

// The interface between the Flutter rasterizer and the underlying platform. May
14 15
// be constructed on any thread but will be used by the engine only on the
// raster thread.
16 17
class Surface final : public flutter::Surface {
 public:
18 19
  Surface(std::string debug_label,
          flutter::ExternalViewEmbedder* view_embedder);
20 21 22 23 24 25

  ~Surface() override;

 private:
  const bool valid_ = CanConnectToDisplay();
  const std::string debug_label_;
26
  flutter::ExternalViewEmbedder* view_embedder_;
27 28 29 30 31 32

  // |flutter::Surface|
  bool IsValid() override;

  // |flutter::Surface|
  std::unique_ptr<flutter::SurfaceFrame> AcquireFrame(
33
      const SkISize& size) override;
34 35 36 37 38 39 40

  // |flutter::Surface|
  GrContext* GetContext() override;

  // |flutter::Surface|
  SkMatrix GetRootTransformation() const override;

41 42 43
  // |flutter::Surface|
  flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override;

44 45 46 47 48 49
  static bool CanConnectToDisplay();

  FML_DISALLOW_COPY_AND_ASSIGN(Surface);
};

}  // namespace flutter_runner