forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass SurfaceFrame to SubmitFrame (flutter#18709)
- Loading branch information
Emmanuel Garcia
authored
Jun 3, 2020
1 parent
33a1f1a
commit 243bb59
Showing
21 changed files
with
175 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// 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. | ||
|
||
#include "flutter/shell/common/surface_frame.h" | ||
|
||
#include "flutter/fml/logging.h" | ||
|
||
namespace flutter { | ||
|
||
SurfaceFrame::SurfaceFrame(sk_sp<SkSurface> surface, | ||
bool supports_readback, | ||
const SubmitCallback& submit_callback) | ||
: surface_(surface), | ||
supports_readback_(supports_readback), | ||
submit_callback_(submit_callback) { | ||
FML_DCHECK(submit_callback_); | ||
} | ||
|
||
SurfaceFrame::~SurfaceFrame() { | ||
if (submit_callback_ && !submitted_) { | ||
// Dropping without a Submit. | ||
submit_callback_(*this, nullptr); | ||
} | ||
} | ||
|
||
bool SurfaceFrame::Submit() { | ||
if (submitted_) { | ||
return false; | ||
} | ||
|
||
submitted_ = PerformSubmit(); | ||
|
||
return submitted_; | ||
} | ||
|
||
bool SurfaceFrame::IsSubmitted() const { | ||
return submitted_; | ||
} | ||
|
||
SkCanvas* SurfaceFrame::SkiaCanvas() { | ||
return surface_ != nullptr ? surface_->getCanvas() : nullptr; | ||
} | ||
|
||
sk_sp<SkSurface> SurfaceFrame::SkiaSurface() const { | ||
return surface_; | ||
} | ||
|
||
bool SurfaceFrame::PerformSubmit() { | ||
if (submit_callback_ == nullptr) { | ||
return false; | ||
} | ||
|
||
if (submit_callback_(*this, SkiaCanvas())) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
} // namespace flutter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// 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. | ||
|
||
#ifndef FLUTTER_SHELL_COMMON_SURFACE_FRAME_H_ | ||
#define FLUTTER_SHELL_COMMON_SURFACE_FRAME_H_ | ||
|
||
#include <memory> | ||
|
||
#include "flutter/fml/macros.h" | ||
#include "third_party/skia/include/core/SkCanvas.h" | ||
#include "third_party/skia/include/core/SkSurface.h" | ||
|
||
namespace flutter { | ||
|
||
/// Represents a Frame that has been fully configured for the underlying client | ||
/// rendering API. A frame may only be submitted once. | ||
class SurfaceFrame { | ||
public: | ||
using SubmitCallback = | ||
std::function<bool(const SurfaceFrame& surface_frame, SkCanvas* canvas)>; | ||
|
||
SurfaceFrame(sk_sp<SkSurface> surface, | ||
bool supports_readback, | ||
const SubmitCallback& submit_callback); | ||
|
||
~SurfaceFrame(); | ||
|
||
bool Submit(); | ||
|
||
bool IsSubmitted() const; | ||
|
||
SkCanvas* SkiaCanvas(); | ||
|
||
sk_sp<SkSurface> SkiaSurface() const; | ||
|
||
bool supports_readback() { return supports_readback_; } | ||
|
||
private: | ||
bool submitted_ = false; | ||
sk_sp<SkSurface> surface_; | ||
bool supports_readback_; | ||
SubmitCallback submit_callback_; | ||
|
||
bool PerformSubmit(); | ||
|
||
FML_DISALLOW_COPY_AND_ASSIGN(SurfaceFrame); | ||
}; | ||
|
||
} // namespace flutter | ||
|
||
#endif // FLUTTER_SHELL_COMMON_SURFACE_FRAME_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.