summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwonsik@google.com <wonsik@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-04 06:31:21 +0000
committerwonsik@google.com <wonsik@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-04 06:31:21 +0000
commiteadbaaf32f299ba14e6b792e4851322c287d4a4a (patch)
treec1e83b3cd17fc73e153da0d49fbc96f9b4723755
parent88ac5c023116aa501b9fd9eeac102f4f0b8f4419 (diff)
downloadchromium_src-eadbaaf32f299ba14e6b792e4851322c287d4a4a.zip
chromium_src-eadbaaf32f299ba14e6b792e4851322c287d4a4a.tar.gz
chromium_src-eadbaaf32f299ba14e6b792e4851322c287d4a4a.tar.bz2
Implement "hole" video frame.
In order to support out-of-band compositing of protected video content in Chrome, it is necessary to have a transparent hole in Chrome's HTML rendering so that video playing "beneath" the HTML elements can be seen through. To accomplish the scenario stated above, define a "hole" video frame which would clear the region where video would have been composited. In CC, this is done by sending a transparent black SolidColorDrawQuad with blending disabled. Review URL: https://chromiumcodereview.appspot.com/12255032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185841 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/video_layer_impl.cc38
-rw-r--r--content/browser/renderer_host/media/video_capture_controller.cc4
-rw-r--r--media/base/video_frame.cc11
-rw-r--r--media/base/video_frame.h8
4 files changed, 61 insertions, 0 deletions
diff --git a/cc/video_layer_impl.cc b/cc/video_layer_impl.cc
index 8a624bfa..502ccc2 100644
--- a/cc/video_layer_impl.cc
+++ b/cc/video_layer_impl.cc
@@ -20,6 +20,10 @@
#include "third_party/khronos/GLES2/gl2.h"
#include "third_party/khronos/GLES2/gl2ext.h"
+#if defined(GOOGLE_TV)
+#include "cc/solid_color_draw_quad.h"
+#endif
+
namespace cc {
// static
@@ -89,6 +93,10 @@ static GLenum convertVFCFormatToGLenum(const media::VideoFrame& frame)
return GL_LUMINANCE;
case media::VideoFrame::NATIVE_TEXTURE:
return frame.texture_target();
+#if defined(GOOGLE_TV)
+ case media::VideoFrame::HOLE:
+ return GL_INVALID_VALUE;
+#endif
case media::VideoFrame::INVALID:
case media::VideoFrame::RGB32:
case media::VideoFrame::EMPTY:
@@ -108,6 +116,10 @@ size_t VideoLayerImpl::numPlanes() const
return 1;
switch (m_frame->format()) {
+#if defined(GOOGLE_TV)
+ case media::VideoFrame::HOLE:
+ return 0;
+#endif
case media::VideoFrame::RGB32:
return 1;
case media::VideoFrame::YV12:
@@ -152,6 +164,11 @@ void VideoLayerImpl::willDrawInternal(ResourceProvider* resourceProvider)
if (!m_frame)
return;
+#if defined(GOOGLE_TV)
+ if (m_frame->format() == media::VideoFrame::HOLE)
+ return;
+#endif
+
m_format = convertVFCFormatToGLenum(*m_frame);
// If these fail, we'll have to add draw logic that handles offset bitmap/
@@ -215,6 +232,27 @@ void VideoLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuad
const float texHeightScale =
static_cast<float>(visibleRect.height()) / codedSize.height();
+#if defined(GOOGLE_TV)
+ // This block and other blocks wrapped around #if defined(GOOGLE_TV) is not
+ // maintained by the general compositor team. Please contact the following
+ // people instead:
+ //
+ // wonsik@chromium.org
+ // ycheo@chromium.org
+
+ if (m_frame->format() == media::VideoFrame::HOLE) {
+ scoped_ptr<SolidColorDrawQuad> solidColorDrawQuad =
+ SolidColorDrawQuad::Create();
+ // Create a solid color quad with transparent black and force no
+ // blending.
+ solidColorDrawQuad->SetAll(
+ sharedQuadState, quadRect, quadRect, quadRect, false,
+ SK_ColorTRANSPARENT);
+ quadSink.append(solidColorDrawQuad.PassAs<DrawQuad>(), appendQuadsData);
+ return;
+ }
+#endif
+
switch (m_format) {
case GL_LUMINANCE: {
// YUV software decoder.
diff --git a/content/browser/renderer_host/media/video_capture_controller.cc b/content/browser/renderer_host/media/video_capture_controller.cc
index aad341d..9b3161b 100644
--- a/content/browser/renderer_host/media/video_capture_controller.cc
+++ b/content/browser/renderer_host/media/video_capture_controller.cc
@@ -465,6 +465,10 @@ void VideoCaptureController::OnIncomingCapturedVideoFrame(
// Do color conversion from the camera format to I420.
switch (frame->format()) {
+#if defined(GOOGLE_TV)
+ case media::VideoFrame::HOLE:
+ // Fall-through to NOTREACHED() block.
+#endif
case media::VideoFrame::INVALID:
case media::VideoFrame::YV16:
case media::VideoFrame::EMPTY:
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc
index 71bdcf4..b5330bd 100644
--- a/media/base/video_frame.cc
+++ b/media/base/video_frame.cc
@@ -135,6 +135,17 @@ scoped_refptr<VideoFrame> VideoFrame::CreateBlackFrame(const gfx::Size& size) {
return CreateColorFrame(size, kBlackY, kBlackUV, kBlackUV, kZero);
}
+#if defined(GOOGLE_TV)
+// static
+scoped_refptr<VideoFrame> VideoFrame::CreateHoleFrame(
+ const gfx::Size& size) {
+ DCHECK(IsValidConfig(VideoFrame::HOLE, size, gfx::Rect(size), size));
+ scoped_refptr<VideoFrame> frame(new VideoFrame(
+ VideoFrame::HOLE, size, gfx::Rect(size), size, base::TimeDelta()));
+ return frame;
+}
+#endif
+
static inline size_t RoundUp(size_t value, size_t alignment) {
// Check that |alignment| is a power of 2.
DCHECK((alignment + (alignment - 1)) == (alignment | (alignment - 1)));
diff --git a/media/base/video_frame.h b/media/base/video_frame.h
index 3483e91..07697c2 100644
--- a/media/base/video_frame.h
+++ b/media/base/video_frame.h
@@ -43,6 +43,9 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
EMPTY = 9, // An empty frame.
I420 = 11, // 12bpp YVU planar 1x1 Y, 2x2 UV samples.
NATIVE_TEXTURE = 12, // Native texture. Pixel-format agnostic.
+#if defined(GOOGLE_TV)
+ HOLE = 13, // Hole frame.
+#endif
};
// Creates a new frame in system memory with given parameters. Buffers for
@@ -125,6 +128,11 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
// equivalent of RGB(0,0,0).
static scoped_refptr<VideoFrame> CreateBlackFrame(const gfx::Size& size);
+#if defined(GOOGLE_TV)
+ // Allocates a hole frame.
+ static scoped_refptr<VideoFrame> CreateHoleFrame(const gfx::Size& size);
+#endif
+
Format format() const { return format_; }
const gfx::Size& coded_size() const { return coded_size_; }