Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Unified Diff: media/renderers/skcanvas_video_renderer.cc

Issue 2143183004: Use SkImage::makeNonTextureImage to perform GPU->CPU readback in skcanvas_video_renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/renderers/skcanvas_video_renderer.cc
diff --git a/media/renderers/skcanvas_video_renderer.cc b/media/renderers/skcanvas_video_renderer.cc
index 74e72bc5a4c5338b654097de6de29fa321a9b611..5454967aa40a15b258ebaa088554bebd20923b19 100644
--- a/media/renderers/skcanvas_video_renderer.cc
+++ b/media/renderers/skcanvas_video_renderer.cc
@@ -429,22 +429,15 @@ void SkCanvasVideoRenderer::Paint(const scoped_refptr<VideoFrame>& video_frame,
-SkFloatToScalar(last_image_->height() * 0.5f));
}
- // This is a workaround for crbug.com/524717. SkBitmaps are read back before a
- // SkPicture is sent to multiple threads while SkImages are not. The long term
- // solution is for Skia to provide a SkPicture filter that makes a picture
- // safe for multiple CPU raster threads (skbug.com/4321). We limit the
- // workaround to cases where the src frame is a texture and the canvas is
- // recording.
- if (last_image_.get()->getTexture() &&
- canvas->imageInfo().colorType() == kUnknown_SkColorType) {
- SkBitmap bmp;
- GrWrapTextureInBitmap(last_image_.get()->getTexture(),
- last_image_.get()->width(),
- last_image_.get()->height(), true, &bmp);
- // Even though the bitmap is logically immutable we do not mark it as such
- // because doing so would defer readback until rasterization, which will be
- // on another thread and is therefore unsafe.
- canvas->drawBitmap(bmp, 0, 0, &paint);
+ // This is a workaround for crbug.com/524717. A texture backed image is not
+ // safe to access on another thread or GL context. So if we're drawing into a
+ // recording canvas we read the texture back into CPU memory and record that
+ // sw image into the SkPicture. The long term solution is for Skia to provide
+ // a SkPicture filter that makes a picture safe for multiple CPU raster
+ // threads. (skbug.com/4321).
+ if (canvas->imageInfo().colorType() == kUnknown_SkColorType) {
+ sk_sp<SkImage> swImage = last_image_->makeNonTextureImage();
+ canvas->drawImage(swImage, 0, 0, &paint);
} else {
canvas->drawImage(last_image_.get(), 0, 0, &paint);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698