Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: content/gpu/media/fake_gl_video_device.cc

Issue 6793054: Moved code that runs in both the browser and GPU process from content/gpu to content/common/gpu. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/gpu/media/fake_gl_video_device.h ('k') | content/gpu/media/gpu_video_device.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/gpu/media/fake_gl_video_device.h"
6
7 #include "media/base/video_frame.h"
8 #include "ui/gfx/gl/gl_bindings.h"
9
10 void* FakeGlVideoDevice::GetDevice() {
11 // No actual hardware device should be used.
12 return NULL;
13 }
14
15 bool FakeGlVideoDevice::CreateVideoFrameFromGlTextures(
16 size_t width, size_t height, media::VideoFrame::Format format,
17 const std::vector<media::VideoFrame::GlTexture>& textures,
18 scoped_refptr<media::VideoFrame>* frame) {
19 media::VideoFrame::GlTexture texture_array[media::VideoFrame::kMaxPlanes];
20 memset(texture_array, 0, sizeof(texture_array));
21
22 for (size_t i = 0; i < textures.size(); ++i) {
23 texture_array[i] = textures[i];
24 }
25
26 media::VideoFrame::CreateFrameGlTexture(format,
27 width,
28 height,
29 texture_array,
30 frame);
31 return *frame != NULL;
32 }
33
34 void FakeGlVideoDevice::ReleaseVideoFrame(
35 const scoped_refptr<media::VideoFrame>& frame) {
36 // We didn't need to anything here because we didin't allocate any resources
37 // for the VideoFrame(s) generated.
38 }
39
40 bool FakeGlVideoDevice::ConvertToVideoFrame(
41 void* buffer, scoped_refptr<media::VideoFrame> frame) {
42 // Assume we are in the right context and then upload the content to the
43 // texture.
44 glBindTexture(GL_TEXTURE_2D,
45 frame->gl_texture(media::VideoFrame::kRGBPlane));
46
47 // |buffer| is also a VideoFrame.
48 scoped_refptr<media::VideoFrame> frame_to_upload(
49 reinterpret_cast<media::VideoFrame*>(buffer));
50 DCHECK_EQ(frame->width(), frame_to_upload->width());
51 DCHECK_EQ(frame->height(), frame_to_upload->height());
52 DCHECK_EQ(frame->format(), frame_to_upload->format());
53 glTexImage2D(
54 GL_TEXTURE_2D, 0, GL_RGBA, frame_to_upload->width(),
55 frame_to_upload->height(), 0, GL_RGBA,
56 GL_UNSIGNED_BYTE, frame_to_upload->data(media::VideoFrame::kRGBPlane));
57 return true;
58 }
OLDNEW
« no previous file with comments | « content/gpu/media/fake_gl_video_device.h ('k') | content/gpu/media/gpu_video_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698