forked from flutter/flutter
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure that Scene::toImage renders texture backed images. (flutter#6636)
TL;DR: Offscreen surface is created on the render thread and device to host transfer performed there before task completion on the UI thread. While attempting to snapshot layer trees, the engine was attempting to use the IO thread context. The reasoning was that this would be safe to do because any textures uploaded to the GPU as a result of async texture upload would have originated from this context and hence the handles would be valid in either context. As it turns out, while the handles are valid, Skia does not support this use-case because cross-context images transfer ownership of the image from one context to another. So, when we made the hop from the UI thread to the IO thread (for snapshotting), if either the UI or GPU threads released the last reference to the texture backed image, the image would be invalid. This led to such images being absent from the layer tree snapshot. Simply referencing the images as they are being used on the IO thread is not sufficient because accessing images on one context after their ownership has already been transferred to another is not safe behavior (from Skia's perspective, the handles are still valid in the sharegroup). To work around these issues, it was decided that an offscreen render target would be created on the render thread. The color attachment of this render target could then be transferred as a cross context image to the IO thread for the device to host tranfer. Again, this is currently not quite possible because the only way to create cross context images is from encoded data. Till Skia exposes the functionality to create cross-context images from textures in one context, we do a device to host transfer on the GPU thread. The side effect of this is that this is now part of the frame workload (image compression, which dominate the wall time, is still done of the IO thread). A minor side effect of this patch is that the GPU latch needs to be waited on before the UI thread tasks can be completed before shell initialization.
- Loading branch information
1 parent
25d0507
commit 20c805c
Showing
16 changed files
with
202 additions
and
117 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2018 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_LIB_UI_SNAPSHOT_DELEGATE_H_ | ||
#define FLUTTER_LIB_UI_SNAPSHOT_DELEGATE_H_ | ||
|
||
#include "third_party/skia/include/core/SkImage.h" | ||
#include "third_party/skia/include/core/SkPicture.h" | ||
|
||
namespace blink { | ||
|
||
class SnapshotDelegate { | ||
public: | ||
virtual sk_sp<SkImage> MakeRasterSnapshot(sk_sp<SkPicture> picture, | ||
SkISize picture_size) = 0; | ||
}; | ||
|
||
} // namespace blink | ||
|
||
#endif // FLUTTER_LIB_UI_SNAPSHOT_DELEGATE_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
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
Oops, something went wrong.