Bug 1288618 - Part 10: Add a new layers::Image type for GPUVideo. r=nical
☠☠ backed out by 8b6401bcb115 ☠ ☠
authorMatt Woodrow <mwoodrow@mozilla.com>
Wed, 21 Sep 2016 15:36:10 +1200
changeset 314690 f8bbdabdb6da5ca1682f2f5656ce49b4b6ac7d2f
parent 314689 8b0adeab93df2ac2b8c1d2a5f5f3ed0958411a7e
child 314691 24df0e89b273f7c196c9ae6b86bd7449f28c9682
push id30732
push usercbook@mozilla.com
push dateWed, 21 Sep 2016 10:04:03 +0000
treeherdermozilla-central@560b2c805bf7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1288618
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1288618 - Part 10: Add a new layers::Image type for GPUVideo. r=nical
gfx/layers/GPUVideoImage.h
gfx/layers/ImageTypes.h
gfx/layers/moz.build
new file mode 100644
--- /dev/null
+++ b/gfx/layers/GPUVideoImage.h
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef GFX_GPU_VIDEO_IMAGE_H
+#define GFX_GPU_VIDEO_IMAGE_H
+
+#include "mozilla/RefPtr.h"
+#include "ImageContainer.h"
+#include "mozilla/layers/GPUVideoTextureClient.h"
+#include "mozilla/layers/CompositableClient.h"
+#include "mozilla/layers/ImageBridgeChild.h"
+
+namespace mozilla {
+namespace layers {
+
+// Image class that refers to a decoded video frame within
+// the GPU process.
+class GPUVideoImage final : public Image {
+public:
+  GPUVideoImage(const SurfaceDescriptorGPUVideo& aSD,
+                const gfx::IntSize& aSize)
+    : Image(nullptr, ImageFormat::GPU_VIDEO)
+    , mSize(aSize)
+  {
+    // Create the TextureClient immediately since the GPUVideoTextureData
+    // is responsible for deallocating the SurfaceDescriptor.
+    mTextureClient =
+      TextureClient::CreateWithData(new GPUVideoTextureData(aSD, aSize),
+                                    TextureFlags::DEFAULT,
+                                    ImageBridgeChild::GetSingleton().get());
+  }
+
+  ~GPUVideoImage() override {}
+
+  gfx::IntSize GetSize() override { return mSize; }
+
+  // TODO: We really want to be able to support this, but it's complex, since we need to readback
+  // in the other process and send it across.
+  virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override { return nullptr; }
+
+  virtual TextureClient* GetTextureClient(CompositableClient* aClient) override
+  {
+    MOZ_ASSERT(aClient->GetForwarder() == ImageBridgeChild::GetSingleton(), "Must only use GPUVideo on ImageBridge");
+    return mTextureClient;
+  }
+
+private:
+  gfx::IntSize mSize;
+  RefPtr<TextureClient> mTextureClient;
+};
+
+} // namepace layers
+} // namespace mozilla
+
+#endif // GFX_GPU_VIDEO_IMAGE_H
--- a/gfx/layers/ImageTypes.h
+++ b/gfx/layers/ImageTypes.h
@@ -92,17 +92,23 @@ enum class ImageFormat {
   /**
    * A share handle to a ID3D11Texture2D.
    */
   D3D11_SHARE_HANDLE_TEXTURE,
 
   /**
    * A wrapper around a drawable TextureClient.
    */
-  TEXTURE_WRAPPER
+  TEXTURE_WRAPPER,
+
+  /**
+   * An opaque handle that refers to an Image stored in the GPU
+   * process.
+   */
+  GPU_VIDEO
 };
 
 enum class StereoMode {
   MONO,
   LEFT_RIGHT,
   RIGHT_LEFT,
   BOTTOM_TOP,
   TOP_BOTTOM,
--- a/gfx/layers/moz.build
+++ b/gfx/layers/moz.build
@@ -20,16 +20,17 @@ EXPORTS += [
     'client/ClientTiledPaintedLayer.h',
     'composite/CompositableHost.h',
     'composite/ImageHost.h',
     'CompositorTypes.h',
     'CopyableCanvasLayer.h',
     'D3D9SurfaceImage.h',
     'FrameMetrics.h',
     'GLImages.h',
+    'GPUVideoImage.h',
     'GrallocImages.h',
     'ImageContainer.h',
     'ImageLayers.h',
     'ImageTypes.h',
     'IMFYCbCrImage.h',
     'ipc/ThreadSafeRefcountingWithMainThreadDestruction.h',
     'Layers.h',
     'LayerScope.h',