summaryrefslogtreecommitdiffstats
path: root/chrome/gpu/media/mft_angle_video_device.cc
blob: 1faf9dcf913bc91d217358484fb5dfa45e93303b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) 2010 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 "chrome/gpu/media/mft_angle_video_device.h"

#include <d3d9.h>

#include "media/base/video_frame.h"
#include "third_party/angle/src/libGLESv2/main.h"

MftAngleVideoDevice::MftAngleVideoDevice()
    : device_(reinterpret_cast<egl::Display*>(
          eglGetCurrentDisplay())->getDevice()) {
}

void* MftAngleVideoDevice::GetDevice() {
  return device_;
}

bool MftAngleVideoDevice::CreateVideoFrameFromGlTextures(
    size_t width, size_t height, media::VideoFrame::Format format,
    const std::vector<media::VideoFrame::GlTexture>& textures,
    scoped_refptr<media::VideoFrame>* frame) {
  media::VideoFrame::GlTexture texture_array[media::VideoFrame::kMaxPlanes];
  memset(texture_array, 0, sizeof(texture_array));

  for (size_t i = 0; i < textures.size(); ++i) {
    texture_array[i] = textures[i];
  }

  media::VideoFrame::CreateFrameGlTexture(format,
                                          width,
                                          height,
                                          texture_array,
                                          frame);
  return *frame != NULL;
}

void MftAngleVideoDevice::ReleaseVideoFrame(
    const scoped_refptr<media::VideoFrame>& frame) {
  // We didn't need to anything here because we didn't allocate any resources
  // for the VideoFrame(s) generated.
}

bool MftAngleVideoDevice::UploadToVideoFrame(
    void* buffer, scoped_refptr<media::VideoFrame> frame) {
  gl::Context* context = (gl::Context*)eglGetCurrentContext();
  // TODO(hclam): Connect ANGLE to upload the surface to texture when changes
  // to ANGLE is done.
  return true;
}