Merge "Update pinImages to report when GPU resource limits are exceeded."
This commit is contained in:
committed by
Android (Google) Code Review
commit
e92d4045eb
@@ -53,11 +53,15 @@ void SkiaDisplayList::updateChildren(std::function<void(RenderNode*)> updateFn)
|
||||
|
||||
bool SkiaDisplayList::prepareListAndChildren(TreeInfo& info, bool functorsNeedLayer,
|
||||
std::function<void(RenderNode*, TreeInfo&, bool)> childFn) {
|
||||
// If the prepare tree is triggered by the UI thread then we must force all
|
||||
// mutable images to be pinned in the GPU cache until the next UI thread
|
||||
// draw
|
||||
if (info.mode == TreeInfo::MODE_FULL) {
|
||||
info.prepareTextures = info.canvasContext.pinImages(mMutableImages);
|
||||
// If the prepare tree is triggered by the UI thread and no previous call to
|
||||
// pinImages has failed then we must pin all mutable images in the GPU cache
|
||||
// until the next UI thread draw.
|
||||
if (info.prepareTextures && !info.canvasContext.pinImages(mMutableImages)) {
|
||||
// In the event that pinning failed we prevent future pinImage calls for the
|
||||
// remainder of this tree traversal and also unpin any currently pinned images
|
||||
// to free up GPU resources.
|
||||
info.prepareTextures = false;
|
||||
info.canvasContext.unpinImages();
|
||||
}
|
||||
|
||||
for (auto& child : mChildNodes) {
|
||||
|
||||
@@ -48,9 +48,11 @@ void SkiaPipeline::onDestroyHardwareResources() {
|
||||
|
||||
bool SkiaPipeline::pinImages(std::vector<SkImage*>& mutableImages) {
|
||||
for (SkImage* image : mutableImages) {
|
||||
mPinnedImages.emplace_back(sk_ref_sp(image));
|
||||
// TODO: return false if texture creation fails (see b/32691999)
|
||||
SkImage_pinAsTexture(image, mRenderThread.getGrContext());
|
||||
if (SkImage_pinAsTexture(image, mRenderThread.getGrContext())) {
|
||||
mPinnedImages.emplace_back(sk_ref_sp(image));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
* remain in the cache until it has been unpinned. We leverage this feature
|
||||
* to avoid making a CPU copy of the pixels.
|
||||
*
|
||||
* @return true if the images have been successfully pinned to the GPU cache
|
||||
* @return true if all images have been successfully pinned to the GPU cache
|
||||
* and false otherwise (e.g. cache limits have been exceeded).
|
||||
*/
|
||||
bool pinImages(std::vector<SkImage*>& mutableImages) {
|
||||
|
||||
Reference in New Issue
Block a user