2018-11-07 12:24:35 -08:00
|
|
|
// Copyright 2013 The Flutter Authors. All rights reserved.
|
2016-10-06 15:06:21 -07:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
#ifndef FLUTTER_SHELL_COMMON_SURFACE_H_
|
|
|
|
|
#define FLUTTER_SHELL_COMMON_SURFACE_H_
|
|
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
2018-04-13 13:48:15 -07:00
|
|
|
#include "flutter/flow/compositor_context.h"
|
2018-10-26 14:26:59 -07:00
|
|
|
#include "flutter/flow/embedded_views.h"
|
2018-07-26 12:49:34 -07:00
|
|
|
#include "flutter/fml/macros.h"
|
2016-10-06 15:06:21 -07:00
|
|
|
#include "third_party/skia/include/core/SkCanvas.h"
|
|
|
|
|
|
2019-04-09 17:10:46 -07:00
|
|
|
namespace flutter {
|
2016-10-06 15:06:21 -07:00
|
|
|
|
2017-01-20 14:37:10 -08:00
|
|
|
/// Represents a Frame that has been fully configured for the underlying client
|
2019-03-05 15:21:06 -08:00
|
|
|
/// rendering API. A frame may only be submitted once.
|
2016-10-06 15:06:21 -07:00
|
|
|
class SurfaceFrame {
|
|
|
|
|
public:
|
2017-02-22 15:40:23 -08:00
|
|
|
using SubmitCallback =
|
|
|
|
|
std::function<bool(const SurfaceFrame& surface_frame, SkCanvas* canvas)>;
|
2016-10-06 15:06:21 -07:00
|
|
|
|
2019-12-11 15:10:55 -08:00
|
|
|
SurfaceFrame(sk_sp<SkSurface> surface,
|
|
|
|
|
bool supports_readback,
|
|
|
|
|
const SubmitCallback& submit_callback);
|
2017-01-20 14:37:10 -08:00
|
|
|
|
|
|
|
|
~SurfaceFrame();
|
2016-10-06 15:06:21 -07:00
|
|
|
|
|
|
|
|
bool Submit();
|
|
|
|
|
|
2017-01-20 14:37:10 -08:00
|
|
|
SkCanvas* SkiaCanvas();
|
2016-10-06 15:06:21 -07:00
|
|
|
|
2017-02-22 15:40:23 -08:00
|
|
|
sk_sp<SkSurface> SkiaSurface() const;
|
|
|
|
|
|
2019-12-11 15:10:55 -08:00
|
|
|
bool supports_readback() { return supports_readback_; }
|
|
|
|
|
|
2016-10-06 15:06:21 -07:00
|
|
|
private:
|
|
|
|
|
bool submitted_;
|
2017-01-20 14:37:10 -08:00
|
|
|
sk_sp<SkSurface> surface_;
|
2019-12-11 15:10:55 -08:00
|
|
|
bool supports_readback_;
|
2017-01-20 14:37:10 -08:00
|
|
|
SubmitCallback submit_callback_;
|
2016-10-06 15:06:21 -07:00
|
|
|
|
2017-01-20 14:37:10 -08:00
|
|
|
bool PerformSubmit();
|
2016-10-06 15:06:21 -07:00
|
|
|
|
2018-07-26 12:49:34 -07:00
|
|
|
FML_DISALLOW_COPY_AND_ASSIGN(SurfaceFrame);
|
2016-10-06 15:06:21 -07:00
|
|
|
};
|
|
|
|
|
|
2019-06-13 16:15:10 -07:00
|
|
|
/// Abstract Base Class that represents where we will be rendering content.
|
2016-10-06 15:06:21 -07:00
|
|
|
class Surface {
|
|
|
|
|
public:
|
2017-04-17 14:07:22 -07:00
|
|
|
Surface();
|
|
|
|
|
|
2016-10-06 15:06:21 -07:00
|
|
|
virtual ~Surface();
|
|
|
|
|
|
|
|
|
|
virtual bool IsValid() = 0;
|
|
|
|
|
|
2019-12-03 12:02:37 -08:00
|
|
|
virtual std::unique_ptr<SurfaceFrame> AcquireFrame(const SkISize& size) = 0;
|
2016-10-06 15:06:21 -07:00
|
|
|
|
2018-08-28 14:13:49 -07:00
|
|
|
virtual SkMatrix GetRootTransformation() const = 0;
|
|
|
|
|
|
2016-10-06 15:06:21 -07:00
|
|
|
virtual GrContext* GetContext() = 0;
|
2017-04-17 14:07:22 -07:00
|
|
|
|
2019-04-17 14:38:45 -07:00
|
|
|
virtual flutter::ExternalViewEmbedder* GetExternalViewEmbedder();
|
2018-10-26 14:26:59 -07:00
|
|
|
|
2019-11-18 18:28:04 -08:00
|
|
|
virtual bool MakeRenderContextCurrent();
|
2018-11-09 17:05:05 -08:00
|
|
|
|
2017-04-17 14:07:22 -07:00
|
|
|
private:
|
2018-07-26 12:49:34 -07:00
|
|
|
FML_DISALLOW_COPY_AND_ASSIGN(Surface);
|
2016-10-06 15:06:21 -07:00
|
|
|
};
|
|
|
|
|
|
2019-04-09 17:10:46 -07:00
|
|
|
} // namespace flutter
|
2016-10-06 15:06:21 -07:00
|
|
|
|
|
|
|
|
#endif // FLUTTER_SHELL_COMMON_SURFACE_H_
|