DescriptionPotential bug on drawing video on SkCanvas
When drawing video frame on SkCanvas, chromium reuse the same cached SkBitmap
on both software SkCanvas and accelerated SkCanvas. After SkBitmap is used on
both SkCanvas, SkBitmap includes both GrTexture and system memory buffer. It's
weird and looks error-prone. Fortunately, it works well.
In detail, SkCanvasVideoRenderer::Paint(VideoFrame* frame, SkCanvas* canvas, ..)
draws |frame| on |canvas|. Paint() makes SkBitmap by |frame| via YUV
conversion or texture uploading and then caches SkBitmap as |last_frame_|.
Paint() can be used by both software SkCanvas and accelerated SkCanvas, and
|last_frame_| is used by both.
|last_frame_| is based on SkImageGenerator, so it's not defined to software
SkBitmap or accelerated SkBitmap at the creation time. When |last_frame_| is
drawn on software canvas, system memory cache is allocated and kept by
|last_frame_|. When |last_frame_| is drawn on accelerated canvas, GrTexture is
allocated and kept by |last_frame_|.
Although it works now, it's not-documented and unexpected behavior of SkBitmap
and SkImageGenerator. It looks like relying on skia implementation detail. This
issue makes SkCanvasVideoRenderer manage software SkBitmap and accelerated
SkBitmap explicitly.
This CL makes software SkBitmap without SkImageGenerator, which is same to the
code before crrev.com/531353002. It's because SkImageGenerator is introduced
to accelerate YUV to RGB conversion on accelerated SkCanvas, not software SkCanvas.
In addition, this CL speeds up performance when both software and accelerated SkCanvas
call Paint() interleavingly. Previously, |last_frame_| uploads YUV texture and converses
to RGB texture every time on accelerated SkCanvas, because software SkCanvas clears
the texture cache.
TEST=https://codereview.chromium.org/656683007/
BUG=424591, 91208
Committed: https://crrev.com/868f4332418328e507ed5b58c9c38ca498e926e2
Cr-Commit-Position: refs/heads/master@{#301947}
Patch Set 1 #
Total comments: 7
Patch Set 2 : Address nits, and use timer #
Total comments: 4
Patch Set 3 : Clean-up Timer code #
Total comments: 3
Patch Set 4 : address nits #
Messages
Total messages: 18 (4 generated)
|