This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Pass SurfaceFrame to SubmitFrame #18709
Merged
blasten
merged 6 commits into
flutter:master
from
blasten:refactor_external_view_embedder
Jun 3, 2020
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this in its own target? The only place this is being included (flow) also includes common.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To workaround a circular dependency.
:commondepends on//flutter/flow, but//flutter/flowdepends on:surface_frame.