Chromecast: media interfaces for hardware-backed video plane.

R=lcwu@chromium.org,damienv@chromium.org
BUG=408189

Review URL: https://codereview.chromium.org/802833002

Cr-Commit-Position: refs/heads/master@{#308456}
diff --git a/chromecast/media/cma/backend/video_plane.cc b/chromecast/media/cma/backend/video_plane.cc
new file mode 100644
index 0000000..192fab8
--- /dev/null
+++ b/chromecast/media/cma/backend/video_plane.cc
@@ -0,0 +1,17 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chromecast/media/cma/backend/video_plane.h"
+
+namespace chromecast {
+namespace media {
+
+VideoPlane::VideoPlane() {
+}
+
+VideoPlane::~VideoPlane() {
+}
+
+}  // namespace media
+}  // namespace chromecast
diff --git a/chromecast/media/cma/backend/video_plane.h b/chromecast/media/cma/backend/video_plane.h
new file mode 100644
index 0000000..6938b8d3
--- /dev/null
+++ b/chromecast/media/cma/backend/video_plane.h
@@ -0,0 +1,54 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROMECAST_MEDIA_CMA_BACKEND_VIDEO_PLANE_H_
+#define CHROMECAST_MEDIA_CMA_BACKEND_VIDEO_PLANE_H_
+
+#include "base/macros.h"
+
+namespace gfx {
+class QuadF;
+class Size;
+}
+
+namespace chromecast {
+namespace media {
+
+class VideoPlane {
+ public:
+  enum CoordinateType {
+    // Graphics plane as coordinate type.
+    COORDINATE_TYPE_GRAPHICS_PLANE = 0,
+
+    // Output video plane as coordinate type.
+    COORDINATE_TYPE_VIDEO_PLANE_RESOLUTION = 1,
+  };
+
+  VideoPlane();
+  virtual ~VideoPlane();
+
+  // Gets video plane resolution.
+  virtual gfx::Size GetVideoPlaneResolution() = 0;
+
+  // Updates the video plane geometry.
+  // |quad.p1()| corresponds to the top left of the original video,
+  // |quad.p2()| to the top right of the original video,
+  // and so on.
+  // Depending on the underlying hardware, the exact geometry
+  // might not be honored.
+  // |coordinate_type| indicates what coordinate type |quad| refers to.
+  virtual void SetGeometry(const gfx::QuadF& quad,
+                           CoordinateType coordinate_type) = 0;
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(VideoPlane);
+};
+
+// Global accessor to the video plane.
+VideoPlane* GetVideoPlane();
+
+}  // namespace media
+}  // namespace chromecast
+
+#endif  // CHROMECAST_MEDIA_CMA_BACKEND_VIDEO_PLANE_H_
diff --git a/chromecast/media/cma/backend/video_plane_fake.cc b/chromecast/media/cma/backend/video_plane_fake.cc
new file mode 100644
index 0000000..a129d8d
--- /dev/null
+++ b/chromecast/media/cma/backend/video_plane_fake.cc
@@ -0,0 +1,36 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chromecast/media/cma/backend/video_plane_fake.h"
+
+#include "base/logging.h"
+#include "base/memory/singleton.h"
+#include "ui/gfx/geometry/quad_f.h"
+#include "ui/gfx/geometry/size.h"
+
+namespace chromecast {
+namespace media {
+
+// static
+VideoPlaneFake* VideoPlaneFake::GetInstance() {
+  return Singleton<VideoPlaneFake>::get();
+}
+
+VideoPlaneFake::VideoPlaneFake() {
+}
+
+VideoPlaneFake::~VideoPlaneFake() {
+}
+
+gfx::Size VideoPlaneFake::GetVideoPlaneResolution() {
+  return gfx::Size(1920, 1080);
+}
+
+void VideoPlaneFake::SetGeometry(const gfx::QuadF& quad,
+                                 CoordinateType coordinate_type) {
+  // Nothing to be done.
+}
+
+}  // namespace media
+}  // namespace chromecast
diff --git a/chromecast/media/cma/backend/video_plane_fake.h b/chromecast/media/cma/backend/video_plane_fake.h
new file mode 100644
index 0000000..f809015
--- /dev/null
+++ b/chromecast/media/cma/backend/video_plane_fake.h
@@ -0,0 +1,37 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROMECAST_MEDIA_CMA_BACKEND_VIDEO_PLANE_FAKE_H_
+#define CHROMECAST_MEDIA_CMA_BACKEND_VIDEO_PLANE_FAKE_H_
+
+#include "base/macros.h"
+#include "base/memory/singleton.h"
+#include "chromecast/media/cma/backend/video_plane.h"
+
+namespace chromecast {
+namespace media {
+
+class VideoPlaneFake : public VideoPlane {
+ public:
+  static VideoPlaneFake* GetInstance();
+
+  // VideoPlane implementation.
+  gfx::Size GetVideoPlaneResolution() override;
+  void SetGeometry(const gfx::QuadF& quad,
+                   CoordinateType coordinate_type) override;
+
+ private:
+  friend struct DefaultSingletonTraits<VideoPlaneFake>;
+  friend class Singleton<VideoPlaneFake>;
+
+  VideoPlaneFake();
+  virtual ~VideoPlaneFake();
+
+  DISALLOW_COPY_AND_ASSIGN(VideoPlaneFake);
+};
+
+}  // namespace media
+}  // namespace chromecast
+
+#endif  // CHROMECAST_MEDIA_CMA_BACKEND_VIDEO_PLANE_FAKE_H_
diff --git a/chromecast/media/cma/backend/video_plane_fake_factory.cc b/chromecast/media/cma/backend/video_plane_fake_factory.cc
new file mode 100644
index 0000000..2345009
--- /dev/null
+++ b/chromecast/media/cma/backend/video_plane_fake_factory.cc
@@ -0,0 +1,16 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chromecast/media/cma/backend/video_plane_fake.h"
+
+namespace chromecast {
+namespace media {
+
+// Global accessor to the video plane.
+VideoPlane* GetVideoPlane() {
+  return VideoPlaneFake::GetInstance();
+}
+
+}  // namespace media
+}  // namespace chromecast
diff --git a/chromecast/media/media.gyp b/chromecast/media/media.gyp
index 4912f78..1051a6b 100644
--- a/chromecast/media/media.gyp
+++ b/chromecast/media/media.gyp
@@ -108,6 +108,10 @@
         'cma/backend/media_pipeline_device_params.h',
         'cma/backend/video_pipeline_device.cc',
         'cma/backend/video_pipeline_device.h',
+        'cma/backend/video_plane.cc',
+        'cma/backend/video_plane.h',
+        'cma/backend/video_plane_fake.cc',
+        'cma/backend/video_plane_fake.h',
       ],
       'conditions': [
         ['chromecast_branding=="Chrome"', {
@@ -117,6 +121,7 @@
         }, {
           'sources': [
             'cma/backend/media_pipeline_device_fake_factory.cc',
+            'cma/backend/video_plane_fake_factory.cc',
           ],
         }],
       ],