summaryrefslogtreecommitdiffstats
path: root/media/base
diff options
context:
space:
mode:
authorrileya@chromium.org <rileya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-16 04:44:56 +0000
committerrileya@chromium.org <rileya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-16 04:44:56 +0000
commitbd92987fc48b9d69f312aa83ece4be1c866e746c (patch)
treebd729c052eb20aa33570d80c19299d0f5e0d1643 /media/base
parentdc34388a2f792f4b8e5d8548d56302b77f4b5d57 (diff)
downloadchromium_src-bd92987fc48b9d69f312aa83ece4be1c866e746c.zip
chromium_src-bd92987fc48b9d69f312aa83ece4be1c866e746c.tar.gz
chromium_src-bd92987fc48b9d69f312aa83ece4be1c866e746c.tar.bz2
Use SkSrc_Mode in SkCanvasVideoRenderer, to prevent transparent video frames from blending with reused image buffer contents.
BUG=392733 TEST=SkCanvasVideoRendererTest.TransparentFrame Review URL: https://codereview.chromium.org/388363002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283338 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base')
-rw-r--r--media/base/video_frame.cc13
-rw-r--r--media/base/video_frame.h5
-rw-r--r--media/base/video_util.cc14
-rw-r--r--media/base/video_util.h7
4 files changed, 39 insertions, 0 deletions
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc
index 74e6cae..f6b49e4 100644
--- a/media/base/video_frame.cc
+++ b/media/base/video_frame.cc
@@ -372,6 +372,19 @@ scoped_refptr<VideoFrame> VideoFrame::CreateBlackFrame(const gfx::Size& size) {
return CreateColorFrame(size, kBlackY, kBlackUV, kBlackUV, kZero);
}
+// static
+scoped_refptr<VideoFrame> VideoFrame::CreateTransparentFrame(
+ const gfx::Size& size) {
+ const uint8 kBlackY = 0x00;
+ const uint8 kBlackUV = 0x00;
+ const uint8 kTransparentA = 0x00;
+ const base::TimeDelta kZero;
+ scoped_refptr<VideoFrame> frame = VideoFrame::CreateFrame(
+ VideoFrame::YV12A, size, gfx::Rect(size), size, kZero);
+ FillYUVA(frame, kBlackY, kBlackUV, kBlackUV, kTransparentA);
+ return frame;
+}
+
#if defined(VIDEO_HOLE)
// This block and other blocks wrapped around #if defined(VIDEO_HOLE) is not
// maintained by the general compositor team. Please contact the following
diff --git a/media/base/video_frame.h b/media/base/video_frame.h
index 8a607e0..2445dd1 100644
--- a/media/base/video_frame.h
+++ b/media/base/video_frame.h
@@ -189,6 +189,11 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
// equivalent of RGB(0,0,0).
static scoped_refptr<VideoFrame> CreateBlackFrame(const gfx::Size& size);
+ // Allocates YV12A frame based on |size|, and sets its data to the YUVA
+ // equivalent of RGBA(0,0,0,0).
+ static scoped_refptr<VideoFrame> CreateTransparentFrame(
+ const gfx::Size& size);
+
#if defined(VIDEO_HOLE)
// Allocates a hole frame.
static scoped_refptr<VideoFrame> CreateHoleFrame(const gfx::Size& size);
diff --git a/media/base/video_util.cc b/media/base/video_util.cc
index 09f37b8..d794674 100644
--- a/media/base/video_util.cc
+++ b/media/base/video_util.cc
@@ -96,6 +96,20 @@ void FillYUV(VideoFrame* frame, uint8 y, uint8 u, uint8 v) {
}
}
+void FillYUVA(VideoFrame* frame, uint8 y, uint8 u, uint8 v, uint8 a) {
+ // Fill Y, U and V planes.
+ FillYUV(frame, y, u, v);
+
+ // Fill the A plane.
+ uint8* a_plane = frame->data(VideoFrame::kAPlane);
+ int a_rows = frame->rows(VideoFrame::kAPlane);
+ int a_row_bytes = frame->row_bytes(VideoFrame::kAPlane);
+ for (int i = 0; i < a_rows; ++i) {
+ memset(a_plane, a, a_row_bytes);
+ a_plane += frame->stride(VideoFrame::kAPlane);
+ }
+}
+
static void LetterboxPlane(VideoFrame* frame,
int plane,
const gfx::Rect& view_area,
diff --git a/media/base/video_util.h b/media/base/video_util.h
index 5788015..702e620 100644
--- a/media/base/video_util.h
+++ b/media/base/video_util.h
@@ -44,6 +44,13 @@ MEDIA_EXPORT void CopyPlane(size_t plane, const uint8* source, int stride,
// Fills |frame| containing YUV data to the given color values.
MEDIA_EXPORT void FillYUV(VideoFrame* frame, uint8 y, uint8 u, uint8 v);
+// Fills |frame| containing YUVA data with the given color values.
+MEDIA_EXPORT void FillYUVA(VideoFrame* frame,
+ uint8 y,
+ uint8 u,
+ uint8 v,
+ uint8 a);
+
// Creates a border in |frame| such that all pixels outside of
// |view_area| are black. The size and position of |view_area|
// must be even to align correctly with the color planes.